3

After installing SQL Server Management Studio 2017 and uninstalling SSMS 2016, Windows 10 shows the "How do you want to open this .sql file" screen every time I try to open a sql file.

How do you want to open this .sql file

When I look at file type association setup, it doesn't show .sql extension:

Choose default apps by file type doesn't showing .sql extension

Is there any fix to this issue without manual registry manipulation and 3rd party utilities?

natenho
  • 166
  • 1
  • 2
  • 7
  • No, I didn't figure it out. I've got another machine so the problem is gone so far. =) tks btw – natenho Apr 01 '18 at 14:30
  • No worries, see this answer: https://superuser.com/questions/1112867/how-do-i-run-a-python-script-from-a-c-shell-without-specifying-whole-path/1116204#1116204 if you want to try what I was referring to however you will need to point all that to .sql and ssms rather than py or whatever but this is the method at least that I believe will fix this issue if you run into it again if the repair feature from Programs and Features doesn't resolve. I also found this too: https://docs.microsoft.com/en-us/sql/relational-databases/scripting/associate-file-extensions-to-a-code-editor – Vomit IT - Chunky Mess Style Apr 01 '18 at 14:36
  • A later version and a different issue. Nevertheless, the steps by Alexander G [here](https://dba.stackexchange.com/questions/234564/how-to-prevent-sql-files-opening-new-instances-of-ssms-17-9-1) resolved the problem you are having for me. Basically, you have to delete a bunch of sql related registry entries, uninstall ssms, and only after that reinstall ssms (restarts in between may or may not be required). – pwilcox Feb 08 '22 at 21:46

4 Answers4

2

All of these answers are wrong. You have to repair SSMS. If you manually reassign .sql files, they will open with SSMS, but not in the proper way, which leads to multiple instances.

In my case repairing was only possibly by re-downloading the installer, as add/remove programs failed when I tried to repair it there.

Dan
  • 172
  • 2
  • 11
1

In Management Studio:

  • Tools
  • Options
  • Text Editor
  • File extension
  • add .sql
  • OK
studiohack
  • 13,468
  • 19
  • 88
  • 118
Marzieh
  • 11
  • 1
-1

In SSMS I clicked on File, Open, File and all of the .sql files in the default location appeared. To test I simply clicked on one and it opened.

  • That is a work-around, but it does not restore the .sql file extensions and therefore does not answer the question. – music2myear Mar 28 '18 at 22:43
-1

To associate a new file extension with SQL Server Management Studio

  1. On the Start menu, point to All Programs, point to Accessories, and then click Windows Explorer.

  2. In Windows Explorer, on the Tools menu, click Folder Options.

  3. In the Folder Options dialog box, on the File Types tab, click New.

  4. In the Create New Extension dialog box, in the File Extension box, type the new file extension that you want to associate, and then click OK. Do not start the extension with a period.

  5. In the Registered file types box, click on your new extension, and then click Change.

  6. In the Open With dialog box, click SSMS - SQL Server Management Studio, and then click OK.

  7. Click Close to close the Folder Options dialog box, and then close Windows Explorer.

Source: To associate a new file extension with SQL Server Management Studio

To associate a new file extension with a code editor in SQL Server Management Studio

  1. In SQL Server Management Studio, from the Tools menu, click Options.

  2. In the Options dialog box, click Text Editor, and then click File Extension.

  3. In the Extension box, type your new file extension.

  4. In the Editor box, click the code editor that you wish to use to open this file type, click Add, and then click OK.

Source: To associate a new file extension with a code editor in SQL Server Management Studio

MeerArtefakt
  • 101
  • 3