how to determine the records affected in an update sql statement in a stored procdure?
Posted on 2004-10-08
If I have a stored procedure like this:
CREATE PROCEDURE spTest
set NOCOUNT ON
UPDATE pwreset SET UpdateDate = getdate()
WHERE UserID = @UserID
--get # of records updated (0 or 1)
--and then do something based on that info
--if #recsAffected > 0
-- select 'true' as result
-- select 'false' as result
SET NOCOUNT OFF
how would I know how many records were affected? I guess I could alter the statement a bit and then do some sort of query to find out if the record is found, but if I can just tell if there was a record updated, it'd save a step...