Stop SSMS from prompting for connection when a sql script is opened

  • Is there a way to configuire SSMS to stop prompting "Connect to Database Engine" when opening a sql script and you are already connected to a database? This is especially annoying when you are opening multiple scripts.

  • change your windows file association for .SQL scripts to something other than SSMS

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • You can provide the default connection information:

    ssms -S.\InstanceName -E {filename}

    But, I don't know of any way to open a file disconnected unless you use the functionality available in SSMS to open the file disconnected.

    If you set SSMS to open an empty environment, you can then use the Open | File Disconnected dialog to open the file and not be prompted for connection information.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • Sorry for not being clearer, I want to open the sql scripts after I have already connected and I want to newly opened files to use the connection that is already established.

  • John (3/23/2009)


    Sorry for not being clearer, I want to open the sql scripts after I have already connected and I want to newly opened files to use the connection that is already established.

    Not sure what the problem is - but, I opened SSMS, opened a new query and set the connection. Then navigated to a .sql file and opened the file. It opened with the current connection and did not prompt me.

    I opened a server in Object Explorer - and any new files I click on from the OS open with that connection.

    Does your system not work the same?

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • Jeffrey Williams (3/23/2009)


    John (3/23/2009)


    Sorry for not being clearer, I want to open the sql scripts after I have already connected and I want to newly opened files to use the connection that is already established.

    Not sure what the problem is - but, I opened SSMS, opened a new query and set the connection. Then navigated to a .sql file and opened the file. It opened with the current connection and did not prompt me.

    I opened a server in Object Explorer - and any new files I click on from the OS open with that connection.

    Does your system not work the same?

    That is my behavior as well

    Depending on where my selection is (say I have 2 servers connected, and my selection focus is on Server #2), the newly opened query will connect to Server #2, even if I have a file query open already connected to Server #1

    SSMS only prompts the Connection dialog when it's a NEW/FIRST connection/file

    SQLServerNewbieMCITP: Database Administrator SQL Server 2005
  • Jeffrey Williams (3/23/2009)

    Not sure what the problem is - but, I opened SSMS, opened a new query and set the connection. Then navigated to a .sql file and opened the file. It opened with the current connection and did not prompt me.

    I opened a server in Object Explorer - and any new files I click on from the OS open with that connection.

    Does your system not work the same?

    Correct. Its maddening. Its like it completely ignores that I'm already connected.

  • Jerry Hung (3/23/2009)


    That is my behavior as well

    Depending on where my selection is (say I have 2 servers connected, and my selection focus is on Server #2), the newly opened query will connect to Server #2, even if I have a file query open already connected to Server #1

    SSMS only prompts the Connection dialog when it's a NEW/FIRST connection/file

    Not mine.

    Im my last job at me last company it was like this. I was hitting SQL2005 boxes with SSMS. In this job I am hitting SQL2000 boxes with SSMS. I wonder if there is some issue with 2k connections that are different than 2k5.

  • Yes - it does seem to be related to SQL Server 2000. I just tried with one of my 2000 boxes and was prompted every time I opened a file.

    Was not prompted if I opened a new query window.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • Anyone have ideas as to why SSMS behaves this way with SQL 2k connections?

  • There have been several items report on Connect about these kinds of issues. In some cases, users wanted a dialog box on every connection - others wanted connections to be re-used.

    What I got from the information is that MS is looking at it for a future version where they may put in an option for the user to decide the default behavior.

    I did not find anything specific to issues with it defaulting to always prompt for SQL Server 2000.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

Viewing 11 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic. Login to reply