I have a query in stored in a variable @query
I execute that query using following statement
I want the number of rows returned by executing above statement in sql server
How can i get that?
This should to the trick:
Just make sure you do it as the VERY NEXT statement... @@rowcount gets set after every SQL statement that returns results.
You can also set a local variable equal to the results:
declare @myVar int
select @myVar = @@rowcount
Hope this helps.