Thursday, 16 March 2017

How to execute a sql statement on multiple SQL Server instances at the same time?


I assume that you are able to connect to all the SQL Server Instances.

Step 1: Open the SQL Server Management Studio, Go to View in main menu and select 'Registered Servers'. Then will display a Registered Servers window as shown in below images.



Step 2: Register all the SQL Server Instances on which you wanted to execute the SQL Statements at the same time.

Right click on the 'Local Server Groups' and choose 'New Server Registration..' as shown in below image.


Step 3: It will open a new window to choose a SQL Server instance name as shown in below image. You can give a name SQL Server instance to display with same name in the list of 'Registered Servers'.

Register all the SQL Server instances one after another by click on SAVE.



Step 4: Now we will see the list of SQL Server instances as shown in below image after registration done.


Step 5: Start a 'New Query'  window by right click on 'Local Server Group' as shown in below image.


Step 6: Now, we can see that the query window has been connected to 'Local Server Groups' instead of connecting to any single SQL Server instance.


Step 7: Change the query results to display.

Go to Tools in main menu. Choose the Options, it will open a window. Expand the Query Results, then expand the SQL Server, select on the 'Multiserver Results'.

Now we can adjust the properties of 'Multiserver Results', in the right side pane as shown in below image. Set 'True' in both options of 'add server name to results' and 'merge results' in order to display the results as a single result set. Then click OK as shown in below image.


Step 8: Start the executing the SQL Statement on multiple SQL Server instances at the same time as shown in below image. 




Thanks and Regards
Chreddy-SQL Trainer
Crystalspiders Institute
+91-733 845 7517
Whats-app: +91 955 313 7753




No comments:

Post a Comment