Blog Post

Multiple Result Sets = Multiple Row Counts

I’m sure this one’s been in SQL Server Management Studio for quite a while, but I never noticed it before now.

Let’s say you’re running a batch in SSMS containing 2 T-SQL Statements. For simplicity’s sake, I’ll do some selects from my Numbers table:

SELECT TOP 10 * FROM Numbers;
SELECT TOP 100 * FROM Numbers;

The “Results” tab appears with 2 result sets. The first has 10 rows, and the second has 100. The rows counter at the bottom right says “110 rows”. All of is exactly what I’ve come to expect. (Click on any screenshot to enlarge)

Row count for the combined result sets:
Screenshot

But wait, there’s more! If you click in the top result set, that counter will change to say only 10 rows. Click on the bottom set and it now says 100. Click back in the query window and it again shows the combined total of 110.
Screenshot

Screenshot

Nifty, eh? Again, I’m sure this is nothing new, just I had never noticed this behavior in SSMS before. Happy querying!

Related Posts

By Bob Pusateri

Bob Pusateri is a Microsoft Data Platform MVP, Microsoft Certified Master of SQL Server, speaker, blogger, volunteer, and author who loves finding new and exciting ways to break and fix things. He works as a consultant and architect, specializing in data, virtualization, and cloud technologies.

Leave a Reply

Your email address will not be published. Required fields are marked *