Superb option run same single query on multiple SQL Server instances

Dear Friends,
Sometimes you stuck in situation where you need to run same set of queries on different servers.
Sometimes it is a real pan when you need to fetch records from all the server then basic approach you follow run query on different instance once by one.

I would like to share here one important facility provided in SQL Server management studio which is

“Register Servers”

With the help of Register Servers option you can run same query for the entire servers which you have registered.
You can access the “Register Servers” option from View ==> Register servers OR by pressing “CTRL + ALT + G” keys.

As shown below fig

Register Servers

Once you press the menu or follow above keys then you will get Register Servers option screen as shown in below fig.

Regiser server screen

You can right click on Local Server Groups and can create your own group also

Create group

Once the group is created you can move your Registered servers on which you want to run query in that group with right click move option on Group Folder

As you did this job your database server will come in the particular group folder as shown in below fig

MylocalGroupRegisterServers

Now right click on your group folder and go for option New Query
As you go for option new query a new query window will be open there
Now write proper query which you want to run on same database at different servers and execute it with F5 option
You will find when you will execute the result will show in query result window which is just below the query with starting column server name.

SinglQueryMultipleResult

Now you have option whether you want merge result or Individual result.
To check that option you need to go Tool –> Option then Query Result option as shown below fig

MergeREsultOption

This trick will help you in many ways to get the results from different server as well as to find results from different servers.

Thanks & Regards,
Rajat Jaiswal
Keep Learning, Keep Sharing

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s