5

Synopsis

This is not a new problem and there are several solutions floating around on Internet.

Problem

When you double click on a .sql file, a new instance of SSMS is opened. I did not have this problem until new SQL Server Management Studio (SSMS 17.9.1) was installed.

What I tried

  • This page lists several solutions suggesting registry changes and file associations, and reinstalling SSMS. None worked.
  • This one has almost the same as the previous link. (SO is so much better than those forums.)
  • Registry changes are shown here with excellent screenshots. I added "%1" but that did not make any difference.
  • The suggestion mentioned on SO did not work either.
  • On DBA, it is mostly talking about raised permissions, which is not the case with my situation.

Workarounds

Yes, I know about these workarounds:

  • Ctrl + O
  • Drag .sql files to SSMS

I am not looking for workarounds.

My environment

Even with the new SSMS 17.9.1 (build: 14.0.17289.0), I am still pointing to SQL Server 2016 (13.0.5233.0). Previously, I was using SSMS June 2016 (build: 13.0.15000.23) with the same SQL Server (13.0.5233.0).

Because of permission, I am not running any application as administrator.


SQL Server versions are listed here.

SQL Server Management Studio versions are listed here.

  • In addition to registry changes and file associations, the first link also mentions downloading a fresh installer and using that to do a repair. That cleared it up for at least one person. Have you tried that? – Doug Deden Apr 11 at 15:22
  • @DougDeden Yes, I reinstalled SSMS too. – Farhan Apr 11 at 15:24
  • 1
    Ugh! The only way I can reproduce your issue is if the existing SSMS was started with "Run as Administrator". As long as I don't do that, double-clicking works as expected. You mentioned that "Run as Admin" is not the case in your situation, but can you double (triple) check that? (Maybe the shortcut got set that way without you realizing it.) – Doug Deden Apr 11 at 15:26
  • Do you see the same issue with SSMS 18 RC1? – Aaron Bertrand Apr 11 at 15:35
  • @DougDeden I am very sure about it. If I get slightly higher privileges, some people will lose sleep. – Farhan Apr 11 at 16:10
3

I have encountered this issue after installing SSMS 18 instead of 17.9. Then I have tried solutions from the list above but none worked. Uninstalling SSMS 18 and installing 17.9 again did not work either. I was finally able to resolve this issue with SSMS 18, but I hope it will fix incorrect behavior of SSMS 17 as well. First of all I've uninstalled SSMS, then I've searched through registry to find and remove all meaningful nodes containing info about SSMS or sql_auto_file. I removed the following nodes (don't forget to backup each of them prior to deleting!):

  • HKEY_CLASSES_ROOT.sql
  • HKEY_CLASSES_ROOT\Applications\Ssms.exe
  • HKEY_CLASSES_ROOT\sql_auto_file
  • HKEY_CURRENT_USER\Software\Microsoft\SQL Server Management Studio
  • Removed all records for ssms in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts
  • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.sql
  • HKEY_USERS.DEFAULT\Software\Microsoft\SQL Server Management Studio

Then I've restarted my PC, then installed SSMS 18, then restarted again. After that SSMS opens sql files in existing SSMS instance and explorer has correct file icon assigned (document with small database icon)

1

The post by Alexander G led me to my answer.

I had the same problem whereby opening .sql files from explorer by double clicking them would open a new instance of SSMS, rather than the existing open one. This was a brand new installation of SQL / SSMS on a new laptop so wasn't caused by a conflict with an earlier version.

My standard user account on the laptop is not an Admin, so SSMS was installed using "run as Administrator". It appears that doing it this way populates the correct user specific registry settings in the administrator's account registry rather than mine.

The particular entries that were wrong which seemed to cause the problem were:

  • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts
  • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.sql

I manually created those entries in the HKEY_USERS hive for my user based on the values created for my administrator user, and now my .sql files open in the existing instance of SSMS.

(I think it's something to do with the assocation to sql_auto_file, rather than ssms.sql15.0)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.