SQL Files open in a new SSMS instance

  • When I double click on a .sql file, it starts up SSMS and loads my file. When I click on a second file, I'd like it to open in the SSMS that is currently running. Right now, it's not doing that. Anyone know where I can go to make the change? Thanks!

    Thanks,

    Chad

  • Any reason why you want to do this? As new SSMS costs more memory than a new tab in existing SSMS

    SQLServerNewbieMCITP: Database Administrator SQL Server 2005
  • Yes, that is what I would like to do - have it open in the SSMS that is already running. Right now it opens a new SSMS everytime I double-click a .sql file and it is much more difficult to manage my open files that way - particularly when they are related in some way. It is much easier to go down a list of tabs than have to ALT-TAB over. I've done some research and found people who have it working that way, I'm not sure why mine isn't... I can get it to work by dragging from Explorer to SSMS, but old habit die hard, and I keep forgetting.

    Thanks,

    Chad

  • Have you found a solution to this issue?

  • No, but I'm getting more accustomed to dragging the file into the window. I guess after doing it for a year it starts to become second nature. If you found something let me know, but I'm almost acclimated and switching now might be difficult. 😛

    Chad

  • I've had the same problem; I assume it is normal behaviour when starting SSMS that way.

    What I do is open SSMS first, and let it connect to the server. Once it's done that, you can double-click on SQL files and they'll all open in separate tabs in the one SSMS instance.

  • I had the same problem. What worked for me was to change a certain registry key.

    For A solution see:

    http://stackoverflow.com/questions/1726577/sql-management-studio-wont-open-scripts-on-double-click

    However, instead of replacing /dde by "%1" I just added (a space and) "%1" at the end.

    Leo

  • Chad Crawford (3/6/2009)


    Yes, that is what I would like to do - have it open in the SSMS that is already running. Right now it opens a new SSMS everytime I double-click a .sql file and it is much more difficult to manage my open files that way - particularly when they are related in some way. It is much easier to go down a list of tabs than have to ALT-TAB over. I've done some research and found people who have it working that way, I'm not sure why mine isn't... I can get it to work by dragging from Explorer to SSMS, but old habit die hard, and I keep forgetting.

    Thanks,

    Chad

    My system works as you want it to.

    What happens when you double-click a file in Explorer is controlled by the following registry keys:

    HKEY_CLASSES_ROOT\sqlwb.sql.9.0

    HKEY_CLASSES_ROOT\.sql

    On my system these keys are configured as follows:

    [HKEY_CLASSES_ROOT\.sql]

    "PerceivedType"="text"

    @="sqlwb.sql.9.0"

    [HKEY_CLASSES_ROOT\.sql\PersistentHandler]

    @="{5e941d80-bf96-11cd-b579-08002b30bfeb}"

    [HKEY_CLASSES_ROOT\sqlwb.sql.9.0]

    @="Microsoft SQL Server Query File"

    [HKEY_CLASSES_ROOT\sqlwb.sql.9.0\DefaultIcon]

    @="c:\\Program Files (x86)\\Microsoft SQL Server\\100\\Tools\\Binn\\VSShell\\Common7\\IDE\\ssms.exe,-10000"

    [HKEY_CLASSES_ROOT\sqlwb.sql.9.0\Shell]

    [HKEY_CLASSES_ROOT\sqlwb.sql.9.0\Shell\Open]

    [HKEY_CLASSES_ROOT\sqlwb.sql.9.0\Shell\Open\Command]

    @="\"c:\\Program Files (x86)\\Microsoft SQL Server\\100\\Tools\\Binn\\VSShell\\Common7\\IDE\\ssms.exe\" /dde"

    [HKEY_CLASSES_ROOT\sqlwb.sql.9.0\Shell\Open\ddeexec]

    @="Open(\"%1\")"

    [HKEY_CLASSES_ROOT\sqlwb.sql.9.0\Shell\Open\ddeexec\application]

    @="sqlwb.9.0"

    [HKEY_CLASSES_ROOT\sqlwb.sql.9.0\Shell\Open\ddeexec\topic]

    @="system"

  • I am having the same problem with SSMS 2012. Unfortunately, sqlwb.sql.9.0 is not for SSMS 2012 so the above will not work.

    Does anyone have a solution for SSMS 2012?

  • This works if you associate .sql files with ssms in file explorer.

    Right-click a .sql file in a TFS solution and select Open with...

    Press Add...
    The Program is C:\Windows\explorer.exe
    Friendly name is Windows Explorer
    Press OK and set as default

  • Do you have some screen shots?  In TFS Pro 2013 when a .sql file is right-clicked there is no Open With...

  • I use VS2015 Pro and a co-worker just confirmed this works in VS2013 also.

    Here is the right click to open with:

    Here is the Add Program and  Set as Default:

  • Finally, something that worked! Thanks!

  • This is a recurring pain for many regardless of the version of SSMS!  After struggling with this inconvenience for too long and striking out in Google, I found a solution!

    My SSMS was running as Administrator.  I turned this off and now opening new Files open in the current running instance of SSMS, and I do not get prompted every time I Launch SSMS!

    Right Click the SSMS icon, Properties, Compatibility tab, un-check "Rn as Administrator".

    Hope this helps!

     

     

     

  • evans911 wrote:

    This is a recurring pain for many regardless of the version of SSMS!  After struggling with this inconvenience for too long and striking out in Google, I found a solution!

    My SSMS was running as Administrator.  I turned this off and now opening new Files open in the current running instance of SSMS, and I do not get prompted every time I Launch SSMS!

    Right Click the SSMS icon, Properties, Compatibility tab, un-check "Rn as Administrator".

    Hope this helps!

    What version of SSMS are you using?  I ask because I don't see a check box for "Run as Administrator" in any SSMS icon on my system.  I'm using the latest SSMS and SQLServer 2016 and 2017 and I don't recall seeing such a thing in 2008 or any other version of SSMS.  Yep... there's an entry where I can select to run as administrator but but there's no checkbox.

     

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 15 posts - 1 through 15 (of 16 total)

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