Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

SSMS Results Expand / Collapse
Author
Message
Posted Thursday, October 1, 2009 9:21 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, December 12, 2014 1:28 PM
Points: 309, Visits: 730
I'm managing 100's of servers. I have a generic tsql script that can exec any tsql dynamically/remotely at each server using a linked server. The only problem is that in the SSMS results window, I get a separate result set for each server. I really need just one result set so I can dump it all to a file. Any help?

.
Post #796741
Posted Friday, October 2, 2009 7:10 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Thursday, December 18, 2014 8:26 AM
Points: 10,381, Visits: 13,436
Modify the script to dump the results of each query to a temp table and then finish with a select from the temp table.



Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Post #796867
Posted Friday, October 2, 2009 12:07 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, December 12, 2014 1:28 PM
Points: 309, Visits: 730
Thanks for the response Jack!

So create the temp table in the the shell that executes the remote script, or in the remote script that gets executed? I hope that makes sense.


.
Post #797133
Posted Friday, October 2, 2009 1:15 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Thursday, December 18, 2014 8:26 AM
Points: 10,381, Visits: 13,436
I'd do it like this:

Create Table #results(...)

Insert into #results
Select ... from local table

Insert into #results
Select ... from linked table
....

Select * from #results





Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Post #797174
Posted Friday, October 2, 2009 7:40 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, December 12, 2014 1:28 PM
Points: 309, Visits: 730
Here's some psuedo code of what I'm doing

set @SqlTxt = 'select SomeCol from SomeTable'

select SvrName from syssevers
while SvrName is not null
begin
exec(@SqlTxt) AT [SvrName]
select next SvrName
end

The exec is really executing on a remote server. Where would I create the temp table in this scenario? Inside the exec?

Thanks!


.
Post #797331
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse