Reputation: 6428
I have created one dynamic query and it all works well. I execute the query using:
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:)
Upvotes: 2
Views: 5401
Reputation: 1
use the count() function of SQL EXEC sp_executesql @SQLQuery
DECLARE @rownum as int
SET @rownum = (SELECT count([column]) from [tablename])
Upvotes: -1
Reputation: 15433
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
Upvotes: 5