Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hi All,I have to run one alter statement in 50 servers and 1 database per server. I have the list of servers and database in one table. How can i configure the connection manger to achieve thiseg: execute script1 in SQLserver1 /DB1 then connect to SQLserver2 /DB1 etc till SQLserver50 /DB1 Thanks,Roshan
Lumbago
Norsk Yak Master
3271 Posts
Posted - 2010-12-09 : 07:40:33
Loop through the list of servers and databases and perform the required query using OPENROWSET. Pseudo-code:
Declare cur for SELECT server, database FROM tablewhile ... SELECT a.* FROM OPENROWSET('SQLNCLI', 'Server=' + @Servername + ';Trusted_Connection=yes;', 'SELECT Col1 FROM ' + @databasename + '.dbo.sometable') AS a;
- LumbagoMy blog (yes, I have a blog now! just not that much content yet) -> www.thefirstsql.com