I have created one dynamic query and it all works well. I execute the query usin开发者_Go百科g:
EXEC sp_executesql @SQLQuery
where @SQLQuery is one dynamic query.
My only question is how can I also return the number of rows present after the execution of this query? I hope my question is clear.
Thanks in advance:)
You can use the @@rowcount
which will return you the last query effected row count.
EXEC sp_executesql @SQLQuery
DECLARE @rowcount int
SET @rowcount = @@rowcount
SELECT @rowcount as NumofRows
use the count() function of SQL EXEC sp_executesql @SQLQuery
DECLARE @rownum as int
SET @rownum = (SELECT count([column]) from [tablename])
精彩评论