SSMS Change Connection for Query Editor Window

JumpingJezza picture JumpingJezza · Jun 26, 2012 · Viewed 7.6k times · Source

Normally when I want to change the connection for a Query Editor Window in SQL Server Management Studio, I can select a new connection from the menus at the top - Query > Connection > Change Connection.

However, when I am working on cubes with an analysis services connection - and then open a saved SQL script (such as the underlying SQL view) the Available Databases combobox is blank, and the "Change Connection" and other 3 options in that menu (Connect, Disconnect, Disconnect all queries) are all greyed out.

The only workaround I have found to be able to run the saved SQL script, is to open a "New Query" from the SQL Database I want to access in the Object Explorer, and either copy my script into it, or reopen the script - which now opens as normal, with the new query's database.

It seems to be taking the last Query Editor Window's database connection as the default connection for any new queries - and when your last "query" is browsing a cube then it breaks? Does anyone have a fix to un-grey out the "Change Connection" option properly?

I am using SQL Server 2008 R2, and opening the saved SQL script by the File > Open > File menu

Answer

TarasB picture TarasB · May 17, 2013

Luckily in SSMS 2008-R2, 2012 There is a change connection function. Placed just before the DB dropdown. Or via menu Query>Connection>Change Connection.