Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSMS Change Connection for Query Editor Window

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

like image 693
JumpingJezza Avatar asked Jun 26 '12 03:06

JumpingJezza


People also ask

How do I change a connection to a query?

To change the connection associated with a query In Query Editor, right-click a blank area of Query Editor, point to Connection, and then click Change Connection.

How do I change connection properties in SSMS?

In SQL Server Configuration Manager, select SQL Server Services. In the details pane, right-click SQL Server (<instancename>), and then select Properties. In the SQL Server (<instancename>) Properties dialog box, change the server properties on the Service tab or the Advanced tab, and then select OK.

How do I connect to a SQL Server server from a different query?

Start the SQL Server, in the dialog window for the Server name enters the name of the instance that you want to connect with. From the Authentication drop down box, select the SQL Server Authentication and for the field Login and the Password enter your credentials then click the Connect button.


1 Answers

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.

like image 176
TarasB Avatar answered Nov 17 '22 13:11

TarasB