SQL Serverous

SQL Serverous

Alan Wood  //  Professionally: SQL Server consultant
Personally: Geek, musician, sports fan (avid follower of Motherwell in the SPL and the 49ers and Dolphins in the NFL. Also follow the SF Giants in MLB).

Jan 12 / 5:59am

Running scripts on multiple servers in SSMS 2008

SQL Server Management Studio 2008 has a new feature, the ability to run a script on multiple servers at once.  To set this up, the servers need to be registered to a Server Group in the Registered Servers window (see image).  Right-clicking on the Server Group and selecting New Query creates a query window which is connected to the servers in the group (as long as the connection information is correct and the passwords, if using SQL Server Authentication, are saved).  Running a simple query on the master database, in this case:

select top 5 * from sys.columns

returns the top 5 rows from that table from each server.  See the results in the attached image.

The option to Merge Results is True by default.  In a case where the schemas are not identical, this would need to be set to False otherwise an error will be thrown.

     

Loading mentions Retweet

0 comments

Leave a comment...

 
Got an account with one of these? Login here, or just enter your comment below.
Posterous-login    Connect    twitter