November 18, 2001 at 9:14 pm
Sometimes you need to dynamically construct insert/update statement inside of your stored procedure. In this case you can not use @@rowcount variable to determine if anything happened to the updated table. Do you know any other way to check if something happened to the table after execution of dynamically constructed SQL string?
Thanks,
Alex
November 19, 2001 at 5:48 am
You can use sp_executesql to run the d-sql - set a return parameter from @@rowcount and return that.
There is an example of using sp_executesql to return parameters from d-sql and d-sql SP calls at
sp_executeSQL
Cursors never.
DTS - only when needed and never to control.
November 19, 2001 at 10:06 am
Hey!!!
Where's our link!!!!!!!!!!!!!!!!!!1
BTW, Nice answer to this question.
Steve Jones
November 19, 2001 at 6:27 pm
Sorry - that site (amazing grapics!) is hosted by ntl and I've lost the ability to update it.
I'll add you when I move it somewhere else. Plan to host it at home but paid work keeps getting in the way.
I started it to hold the sp_executesql item as I can never remember the syntax and the help is not very clear.
Cursors never.
DTS - only when needed and never to control.
November 20, 2001 at 7:27 am
Sorry , This is the right answer , i've used the pubs database for the sample query
DECLARE @sql Nvarchar(500),
@Var NVarchar(100),
@rc int
SET @Var = '@RC int output'
SET @sql = 'UPDATE authors set phone = phone where contract = 1 SELECT @li = @@ROWCOUNT'
EXEC Sp_ExecuteSql @sql , @Var , @rc OutPut
PRINT @rc
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply