4

I'm using Windows 8 and I'm trying to make Visual Studio 2012 the default program with which to open my .sql files.

I have right-clicked on a .sql file and chosen: Open with... > Choose default program... > More options > Look for another app on this PC. I use the form to open C:\Program Files\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe, but I then get the following error:

Cannot associate file type with this program

The program you have selected cannot be associated with this file type. Please choose another program.

I have associated .sql files with the Microsoft SQL Server Data Tools, T-SQL Editor under Tools > Options > Text Editor > File Extension. However, I believe this is just for syntax highlighting.

Whilst looking for a solution, I found this SO.SE question: https://stackoverflow.com/questions/7471739/how-to-add-a-new-file-association-to-visual-studio. However, I'm hoping for a solution that does not involve using a third-party program.

I also found this SO.SE question: https://stackoverflow.com/questions/15996907/reassociate-files-types-for-visual-studio-2012. However, I don't see .sql in the list of available file extensions.

Is it possible to set Visual Studio 2012 as the default editor for .sql files and, if it is, how can this be achieved on Windows 8?

3
  • Did you tried the registry trick? May 26, 2013 at 11:13
  • @The_aLiEn What registry trick? (that's a no :))
    – m-smith
    Jun 6, 2013 at 7:57
  • 1
    In registry you can search for extension and change associated application to which you want. Extension associations are in HKEY_CLASSES_ROOT Jun 6, 2013 at 22:37

1 Answer 1

1

You're half way of the solution.

To make VS as default editor to your SQL files.

  • Right-click on any .sql file extension.
  • Choose Open With.
  • Now Choose Another app
  • From the list, search for Microsoft Visual Studio Version Selector
  • Make it your Default app

if the application didn't appear in the list, You can also find it at this location

32-bit

%ProgramFiles%\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe

64-bit

%ProgramFiles(x86)%\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe
2
  • aaaand warning to future readers: for many, if not most use cases, it is pointless to associate visual studio with a file type that it is not already associated with, (at least using the above mechanism,) because if you do that, and then you try and open a file of that type from within Winows Explorer, while an instance of Visual Studio is already open, then that file will not be opened in the already-running instane of Visual Studio. Instead, a new instance of Visual Studio will be launched just for that one file. That's pointless and retarded.
    – Mike Nakis
    Jun 3, 2020 at 8:24
  • @MikeNakis if you have an opened instance of VS, you can drag and drop the file to open it in the same instance. Because opening a file will run on a new instance in any program, that's the default of the system, unless the app is programmed to open in an active instance. Like Notepad++, it checks for an active instance before opening a new instance, and open the file using that active instance.
    – iSR5
    Jun 3, 2020 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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