0

I have the following stored procedure that does produce the error specified under Management Studio 2008. But produces output under Management Studio 2012? Any ideas?

ALTER PROCEDURE SPU_IsoEmailUpdate

@isoNumber char(10),
@newEmailAddress varchar(40),
@userName varchar(50),
@oldEmailAddress varchar(40) output
AS

DECLARE @oldEmail varchar(40)
BEGIN TRANSACTION

        SELECT @oldEmail = email FROM iso WHERE isonum = @isoNumber
        SELECT @oldEmailAddress = @oldEmail 

        INSERT INTO IsoEmailHistory (isonum, oldemailaddress, newemailaddress, updatedate, username)
        VALUES(@isoNumber, @oldEmail, @newEmailAddress, GETDATE(), @userName)
        IF @@ERROR <> 0     
        BEGIN
            ROLLBACK
            RAISERROR('Error inserting new Email Address.', 16, 1)
            RETURN
        END 

        IF EXISTS (SELECT isonum FROM iso WHERE isonum = @isoNumber)
        BEGIN
            UPDATE iso SET email = @newEmailAddress 
            WHERE isonum = @isoNumber
        END 
        IF @@ERROR <> 0
        BEGIN
            ROLLBACK
            RAISERROR ('Error updating email Address.', 16, 1)
            RETURN
        END

COMMIT TRANSACTION

That's how I execute it:

declare @oldEmailValue varchar(40)
exec spu_isoemailupdate '222222222', 'testing@newemail.com', 'username', @oldEmailValue output
select @oldEmailValue 'OldEmail'

But it seems that I'm doing something wrong here, since I'm getting the following error:

"Procedure or function SPU_IsoEmailUpdate has too many arguments specified."

What am I doing wrong? Thank you

eugene.it
  • 417
  • 3
  • 13
  • 32

2 Answers2

0

I found why it happened. I tried to look at my stored procedure description by using

sp_help myProcName

And saw that my stored procedure was actually defined with less parameters than I was passing to it.

SO, what happened was, I had two more stored procedures with the same name under another user name and apparently, when calling exec myProcName the wrong one was called. So, I had to delete extra once and everything worked just fine.

I know, that it may be an easy questions but, it may happen to anyone, so I decided to post my solution here.

eugene.it
  • 417
  • 3
  • 13
  • 32
-1

try this

exec spu_isoemailupdate 
@isoNumber = '222222222', 
@newEmailAddress = 'testing@newemail.com',
@userName = 'username', 
@oldEmailValue = ''
Thit Lwin Oo
  • 3,388
  • 3
  • 20
  • 23