Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Single SP for Insert and Update

Author  Topic 

stpn
Starting Member

8 Posts

Posted - 2014-04-04 : 05:37:39
Hi all,

I Want to write a single SP which inserts and updates.

CREATE PROCEDURE sp_NewPassword
@UserName nvarchar(50),
@OldPassword nvarchar(50),
@NewPassword nvarchar(50)
AS
BEGIN
INSERT INTO RGH_ChangePassword(vUserName, vNewPassword) VALUES(@UserName, @NewPassword)
UPDATE RGH_LoginMaster SET vPassword=@NewPassword WHERE vUserName=@vUserName and vPassword=@OldPassword
END

When i tried to create above sp it gives me an error saying

Msg 137, Level 15, State 2, Procedure sp_NewPassword, Line 8
Must declare the scalar variable "@vUserName".

GUIDE ME ON THIS.

Thank you

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2014-04-04 : 05:42:33
Wouldn't it be good to use @UserName instead of @vUserName?


Too old to Rock'n'Roll too young to die.
Go to Top of Page
   

- Advertisement -