We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,134 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

RowCount after executing a query

I have a query in stored in a variable @query

I execute that query using following statement

execute(@query)

I want the number of rows returned by executing above statement in sql server

How can i get that?

2
Contributors
1
Reply
1 Hour
Discussion Span
1 Year Ago
Last Updated
2
Views
MARKAND911
Junior Poster
138 posts since Nov 2008
Reputation Points: 10
Solved Threads: 2
Skill Endorsements: 0

This should to the trick:

select @@rowcount

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.

BitBlt
Practically a Posting Shark
894 posts since Feb 2011
Reputation Points: 482
Solved Threads: 148
Skill Endorsements: 14

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0575 seconds using 2.67MB