April 7, 2026 at 7:40 pm
I am annoyed. We have a CMS server that has hundreds of servers saved to the "node." I need to query them all at once to get a COUNT of a certain value. I want a total across all the servers, not the total on each server. But because CMS keeps throwing Server Name as the first column in every query I write, I'm getting individual server counts, not the end total.
SELECT ... INTO doesn't work because if I use a local temp table, the totals won't carry over to the other servers. If I use a global temp table, it already exists.
Likewise, creating the table in advance. The kicker is no matter what I do, that Server Name column keeps popping up and preventing me from getting a SUM() or a COUNT() over the total.
For Reasons, I cannot export the data or save it into a database. Does anyone have another solution?
April 8, 2026 at 2:38 pm
This was removed by the editor as SPAM
April 8, 2026 at 8:10 pm
Thanks for posting your issue and hopefully someone will answer soon.
This is an automated bump to increase visibility of your question.
April 8, 2026 at 9:06 pm
Hi Brandie, will writing a subquery work for this issue? Such as the below example?
select sum(count)
from
( select servername, count = count(*)
from CMSservers
group by servername
) a1
Tung Dang
Azure and SQL Server DBA Contractor / Consultant
SQL Brainbox - SQL Server Monitoring Tool
April 9, 2026 at 12:45 pm
It will not. I have tried subquerys and the server name still gets added to the top SELECT list, ruining my totals.
It appears I will have to query from another source (like PowerShell) instead of an SSMS window. I will try that.
April 9, 2026 at 4:59 pm
It sounds like you are running the query across multiple SERVERS, not databases or tables, then you really only have 3 options:
1- use linked servers
2- export to file instead of screen and parse it in an external tool.
3- build a report (power BI, ssrs, etc)
The above is all just my opinion on what you should do.
As with all advice you find on a random internet forum - you shouldn't blindly follow it. Always test on a test server to see if there is negative side effects before making changes to live!
I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply