Thursday, December 31, 2009

Stored procedure:Out put Parameter..using @@rowcount

Please check the below example:

alter PROCEDURE UpdateLogin
@UserName nvarchar(15),
@UpdateCount int OUTPUT
AS
update login set username=@UserName where userid<4
select @UpdateCount = @@rowcount
RETURN @UpdateCount

DECLARE @TheCount INT
exec UpdateLogin @UserName = 'sa', @UpdateCount = @TheCount OUTPUT
SELECT TheCount = @TheCount

No comments:

Post a Comment