December 8, 2015 at 12:08 pm
Hey guys, trying to create a stored proc that updates records and returns the number of records updated. Below is my code but its not returning the value. Any ideas on what im doing wrong?:
Alter PROCEDURE [dbo].[spG_Update_EDPS_Staging_Status]
@Group varchar(10),
@NumRowsChanged int OUTPUT
AS
BEGIN
SET NOCOUNT ON;
Update [dbo].[MyTable]
Set Status = 'Loaded'
Where Status = 'Ready' and [FILE_GROUPING] = @Group
Select @NumRowsChanged = @@ROWCOUNT
END
GO
December 8, 2015 at 12:18 pm
SP returns output parameter, but you don't read it. You have to use OUTPUT clause when you run the procedure.
December 8, 2015 at 12:37 pm
Here is the syntax for that.
exec spG_Update_EDPS_Staging_Status @Group, @NumRows OUTPUT
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply