Welcome to MSSQL Forum!
MSSQL Forum - Discussions about Microsoft SQL Server

You are currently viewing our community forums as a guest user. Sign up or
Having an account grants you additional privileges, such as creating and participating in discussions.

Switch Query Environment in SSMS

Discussion in 'SQL Server Scripts and Tools' started by Peter Schmitz, Feb 15, 2016.

  1. Peter Schmitz

    Peter Schmitz Administrator Staff Member

    Learnt this today from a consultant, and since it's a quick little trick, I figured I'd share it.

    When you work in different environments, you sometimes want to test your query from DEV in QA, or from QA in Prod to verify the actual data. I used to copy the query to Clipboard, then connect to the other server, paste the query back in, and then finally set the proper database context. That's a lot of mouse-clicks for something that can be achieved a lot faster.

    Right-click anywhere in the window with your query in it. In the properties menu, pick "Connection", and then "Change Connection":


    You will see the regular connection window. The one thing to keep in mind is that you still need to manually adjust the context of the database the query will be run in.

Share This Page