Share via


SQL file will not open in SSMS on double-click (or jump list)

Question

Friday, October 8, 2010 1:13 PM

Hello, all.

I am running SQL Server Management Studio 2008 on a Windows 7 Enterprise machine here at work.  I am not sure when this started happening, but now, for some reason, when I double-click on a SQL file in Explorer, or from the jump list for SSMS (which I have pinned to my Windows 7 task bar), SSMS will open, but will not load the file in question, nor will it bring up a logon screen to connect to a DB.  I tried unassociating the .SQL extension and then re-associating it using "Open With" and it worked the first time (from the Open With), but then immediately reverted back to its old behavior.  Very annoying.

For now I just open SSMS first (which pops up a logon screen and things proceed normally), but that kind of defeats the purpose of having a jump list or a file association.  Has anybody run into this before and can anybody suggest a fix or what's wrong?

Thanks in advance for any wisdom anyone can provide. 

All replies (27)

Tuesday, January 11, 2011 9:20 PM ✅Answered | 4 votes

Ah... I think the solution is to make the string for

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

say this:

"C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\ssms.exe" "%1" /dde

with quotes around the %1.  It works for me now.

I think this is a bug in SQL Server 2008 client tools.

David Walker


Tuesday, October 11, 2011 5:11 AM ✅Answered | 1 vote

Ah... I think the solution is to make the string for
 
HKEY_CLASSES_ROOT\sqlwb.sql.9.0\Shell\Open\Command
 
say this:
 
"C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\ssms.exe" "%1" /dde
 
with quotes around the %1.  It works for me now.
 
I think this is a bug in SQL Server 2008 client tools.
 
David Walker

Thanks it worked for me as well.Thanks & Regards, Manjunath C Bhat,
http://manjunathcbhat.blogspot.com
http://manjunathcbhat.wordpress.com


Friday, October 8, 2010 1:39 PM | 1 vote

Could you please check what is the value under key

HKEY_CLASSES_ROOT\sqlwb.sql.9.0\Shell\Open\Command - Under (Default)

Balmukund Lakhani | Please mark solved if I've answered your question

This posting is provided "AS IS" with no warranties, and confers no rights.

My Blog: http://blogs.msdn.com/blakhani
Team Blog: http://blogs.msdn.com/sqlserverfaq


Friday, October 8, 2010 2:34 PM

Unfortunately, registry editing has been disabled by group policy.  I can't even use REG QUERY. Mike Loux
Certified Practicing Geek
mike dot loux at gmail dot com


Monday, October 11, 2010 8:12 AM

If this is the case, you may try to reinstall SSMS to see whether it works.

Thanks,
Chunsong

Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.


Wednesday, October 13, 2010 10:30 AM | 2 votes

Right-Click on the .SQL file and Choose Properties.

Then Click on "Change" in the "Open With" Section and Choose "SSMS - SQL Server Management Studio". If this is not available in the list then you may need to click on browse and open this path "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE" and select the "SSMS.exe" and click OK and OK.

Then double click on the .SQL file and it will open in the Management Studio.

Regards,

Sandesh Segu

http://www.SansSQL.com

↑ Grab this Headline Animator


Monday, November 1, 2010 3:34 PM

Right-Click on the .SQL file and Choose Properties.

Then Click on "Change" in the "Open With" Section and Choose "SSMS - SQL Server Management Studio". If this is not available in the list then you may need to click on browse and open this path "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE" and select the "SSMS.exe" and click OK and OK.

Then double click on the .SQL file and it will open in the Management Studio.

Regards,

Sandesh Segu

http://www.SansSQL.com

↑ Grab this Headline Animator

Sorry for the late reply; I was on vacation. 

Tried that, actually.  I set SQL files to open with Notepad to clear existing settings, and then set them again to open with SSMS (and it was available in the list with no issues).  It worked the first time around, but would not work for subsequent openings. 

What's even weirder is that the file is correctly associated with SQL Server, as it DOES open SSMS, it just doesn't pop up a login window to connect to a SQL Server instance.  If, however, SSMS is already open, it loads up and connects just fine.  Doesn't make much sense.

So unfortunately this doesn't fit the bill.  I guess it's not the end of the world for me to open SSMS that first time or open a file twice.  Thanks for trying, all! 

Mike Loux
Certified Practicing Geek
mike dot loux at gmail dot com


Monday, November 1, 2010 3:35 PM

If this is the case, you may try to reinstall SSMS to see whether it works.

Thanks,
Chunsong

Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

If it comes to that, I will try it, but it's just not critical enough to warrant having to get the install media from IT, get admin priveleges to uninstall and then reinstall, etc etc etc.  But the thought has crossed my mind... :-)Mike Loux
Certified Practicing Geek
mike dot loux at gmail dot com


Monday, November 1, 2010 4:07 PM | 2 votes

Hi Mike,
I can provide solution if you can tell me the registry value(HKEY_CLASSES_ROOT\sqlwb.sql.9.0\Shell\Open\Command). I believe there is an extra %1 which is causing this.Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other user's find a solution quicker

This posting is provided "AS IS" with no warranties, and confers no rights.

My Blog: http://blogs.msdn.com/blakhani
Team Blog: http://blogs.msdn.com/sqlserverfaq


Monday, November 1, 2010 5:40 PM

Hi Mike,
I can provide solution if you can tell me the registry value(HKEY_CLASSES_ROOT\sqlwb.sql.9.0\Shell\Open\Command). I believe there is an extra %1 which is causing this. Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other user's find a solution quicker

This posting is provided "AS IS" with no warranties, and confers no rights.

My Blog: http://blogs.msdn.com/blakhani
Team Blog: http://blogs.msdn.com/sqlserverfaq

Let me see if I can get my IT guys to temporarily grant me registry access.  As I said above, it's locked down, but maybe if I ask reeeeally nicely :-)  I will keep you posted.  Thanks!

EDIT: The IT gods have smiled on me.  The value for the key above is "C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\ssms.exe" /dde

Not sure if that helps, but there you go.  Thanks! 

 

Mike Loux
Certified Practicing Geek
mike dot loux at gmail dot com


Monday, November 8, 2010 1:25 PM

Hi Mike,
I can provide solution if you can tell me the registry value(HKEY_CLASSES_ROOT\sqlwb.sql.9.0\Shell\Open\Command). I believe there is an extra %1 which is causing this. Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other user's find a solution quicker

This posting is provided "AS IS" with no warranties, and confers no rights.

My Blog: http://blogs.msdn.com/blakhani
Team Blog: http://blogs.msdn.com/sqlserverfaq

Let me see if I can get my IT guys to temporarily grant me registry access.  As I said above, it's locked down, but maybe if I ask reeeeally nicely :-)  I will keep you posted.  Thanks!

EDIT: The IT gods have smiled on me.  The value for the key above is "C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\ssms.exe" /dde

Not sure if that helps, but there you go.  Thanks! 

 

 

 

Mike Loux
Certified Practicing Geek
mike dot loux at gmail dot com

Replying to myself in case in-place edits don't trigger a "somebody updated this thread" email.  :-)Mike Loux
Certified Practicing Geek
mike dot loux at gmail dot com


Monday, November 8, 2010 1:45 PM | 1 vote

Hi Mike,
I can provide solution if you can tell me the registry value(HKEY_CLASSES_ROOT\sqlwb.sql.9.0\Shell\Open\Command). I believe there is an extra %1 which is causing this. Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other user's find a solution quicker

This posting is provided "AS IS" with no warranties, and confers no rights.

My Blog: http://blogs.msdn.com/blakhani
Team Blog: http://blogs.msdn.com/sqlserverfaq

Let me see if I can get my IT guys to temporarily grant me registry access.  As I said above, it's locked down, but maybe if I ask reeeeally nicely :-)  I will keep you posted.  Thanks!

EDIT: The IT gods have smiled on me.  The value for the key above is "C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\ssms.exe" /dde

Not sure if that helps, but there you go.  Thanks! 

 

 

 

Mike Loux
Certified Practicing Geek
mike dot loux at gmail dot com

Replying to myself in case in-place edits don't trigger a "somebody updated this thread" email.  :-) Mike Loux
Certified Practicing Geek
mike dot loux at gmail dot com

Hey Mike,
Actually edit didnot trigger the email :)

Change that to
"C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\ssms.exe" %1 /dde

(add %1 and that should fix this forever)

Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other user's find a solution quicker

This posting is provided "AS IS" with no warranties, and confers no rights.

My Blog: http://blogs.msdn.com/blakhani
Team Blog: http://blogs.msdn.com/sqlserverfaq


Monday, November 8, 2010 2:55 PM

Yeah, I figured an edit wouldn't trigger an email when I didn't hear back from you right away, as you've always been really quick to reply in the past. 

Sadly, adding the %1 between the command-line and the /dde did not fix the problem.  Now I receive a "There was a problem sending the command to the program." message, plus a usage dialog.  :-(

Mike Loux
Certified Practicing Geek
mike dot loux at gmail dot com


Tuesday, November 9, 2010 2:09 AM | 1 vote

Interesting.. that worked for many customers several times.
If possible, capture process monitor and send me results offline via email?

My email id is blakhani (at) koolmail (dot) inBalmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other user's find a solution quicker

This posting is provided "AS IS" with no warranties, and confers no rights.

My Blog: http://blogs.msdn.com/blakhani
Team Blog: http://blogs.msdn.com/sqlserverfaq


Friday, November 12, 2010 7:29 PM

Just for documentation purposes, I sent Balmukund a process monitor capture of me trying to load a SQL file via the SMSS.EXE jump list yesterday morning, and he is analyzing.  Should be interesting to see what he finds.  :-)Mike Loux
Certified Practicing Geek
mike dot loux at gmail dot com


Monday, November 22, 2010 12:41 PM

Any progress? Kalman Toth, SQL Server & Business Intelligence Training; SQL 2008 GRAND SLAM

I have not heard back from Balmukund as of yet (or if he did reply, it might have gotten marked as $pam, or otherwise filtered in a way that I missed it, in which case, Balmukund, if you're reading this, could you kindly send it to me again?).  The log I sent him was pretty detailed, so I can imagine analyzing it might take a while.  :-)Mike Loux
Certified Practicing Geek
mike dot loux at gmail dot com


Thursday, December 9, 2010 11:32 AM

Any progress? Kalman Toth, SQL Server & Business Intelligence Training; SQL Server 2008 Training

Nope.  Haven't heard a peep.  Mike Loux
Certified Practicing Geek
mike dot loux at gmail dot com


Thursday, December 16, 2010 8:08 AM

Hi,

We've got this error at my working place as well.

I can confirm that adding %1 between the path and the /dde in aforementioned registry value does not work .

Instead this warning message shows up:

 

Microsoft SQL Server Management Studio


The following files were specified on the command line:

J:\kunder\xxx\yyy\Trace
statement
file.sql


These files were not found and will not be loaded.



              OK

As you can see, the open command now seems to misinterpret spaces in the path, or does not handle them correctly.

 


Thursday, December 23, 2010 2:48 PM

Hi,

We've got this error at my working place as well.

I can confirm that adding %1 between the path and the /dde in aforementioned registry value does not work .

Instead this warning message shows up:

 

Microsoft SQL Server Management Studio





The following files were specified on the command line:



J:\kunder\xxx\yyy\Trace

statement

file.sql




These files were not found and will not be loaded.






       OK

As you can see, the open command now seems to misinterpret spaces in the path, or does not handle them correctly.

 

I've had the same experience as both Mike Loux and AndreasJ1974.  I've been fighting with this since I installed SQL Server Express 2008 over top of my SSMS 2005 on this workstation.  I originally just had 2005 tools (SSMS) on this workstation which I used to connect to our SQL 2005 Server.  Everything worked fine then.  When I uninstalled 2005 SSMS from this workstation and installed the full 2008 Express, I believe that's about the time I started noticing this problem (but I could be wrong about that timeline).  I've always blamed 2008 Express for the reason I can no longer open .SQL files.  For the record, I login to the 2005 Server directly, double-click a .SQL file and it opens the file (I can see the code in SSMS) AND asks for a connection.  I'm on XP Pro.

I've tried the %1 trick.  I've tried "Open With".  I've tried Folder Options > File Types.  I tried reinstalling (though I didn't do anything more than uninstall - reinstall.  I didn't comb through the registry and Windows file structure for remnants.

It's just annoyance, but since I've found myself searching for answers 3 or 4 times over the last year, it's apparently more of an annoyance than I'd like to admit.  I'd LOVE to hear a reply from Balmukund.

Thanks and HTH.

Gabe


Thursday, December 23, 2010 3:57 PM | 1 vote

I heard you Gabe.

Can someone tell me exact steps to repro the problem? This really needs investigation.
i will spend some time again with this topic.

Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other user's find a solution quicker

This posting is provided "AS IS" with no warranties, and confers no rights.

My Blog: http://blogs.msdn.com/blakhani
Team Blog: http://blogs.msdn.com/sqlserverfaq


Tuesday, January 11, 2011 9:14 PM

The steps to repro the problem are:

 

1. Install SQL 2008 and all updates, on Windows 7 64-bit.

2. With SSMS closed, double-click on a .sql file WHICH HAS SPACES IN ITS NAME OR PATH.  This may open SSMS, but the file will not be loaded.  If the registry entry mentioned above has the %1, it still won't open the file -- you can imagine what the resulting command line will look like.

3. Notice that there is a "ddeexec" sub-key which has the value Open("%1").  This should help, but it doesn't.  I don't think the solution is to add the %1 in the "command" key (default entry), because spaces in the .sql file name or path won't be handled right.

4. For me, this worked in XP, but not in Windows 7 x64.


Wednesday, January 12, 2011 8:22 PM

Ah... I think the solution is to make the string for

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

say this:

"C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\ssms.exe" "%1" /dde

with quotes around the %1.  It works for me now.

I think this is a bug in SQL Server 2008 client tools.

David Walker

You know, I could have sworn that I tried that (because it makes sense to do so)...but I just tried it (maybe again) and this time, Hallelujah, it worked.  Imagine that.  Good job, David!Mike Loux
Certified Practicing Geek
mike dot loux at gmail dot com


Thursday, September 15, 2011 6:34 PM

Thanks a lot it solve the problem. 

 


Wednesday, November 16, 2011 11:59 PM

HI David,

 

You trick worked for me.

Thanks a lot

 

Suraj


Monday, June 25, 2012 6:46 PM

worked like a charm.  thanks so much!


Friday, September 19, 2014 9:15 AM

Thanks for your solution Sandesh, I was ignoring this annoying bug in ssms since long time. Just tried with all the above steps. Apart from all the regedits, your simple fundamental step worked. 


Thursday, November 27, 2014 9:14 PM | 1 vote

SSMS 2014 Windows 8.1 Fix for this issue:

- Open Regedit
-Navigate to HKEY_CLASSES_ROOT\ssms.sql.12.0
-Back the ssms.sql.12.0 key
-delete the the ssms.sql.12.0 key and subkeys

Copy the text below into notepad and save the file "fix.reg", then merge the contents into your registry.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\ssms.sql.12.0]
@="Microsoft SQL Server Query File"

[HKEY_CLASSES_ROOT\ssms.sql.12.0\DefaultIcon]
@="C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\ssms.exe,-10000"

[HKEY_CLASSES_ROOT\ssms.sql.12.0\Shell]

[HKEY_CLASSES_ROOT\ssms.sql.12.0\Shell\Open]

[HKEY_CLASSES_ROOT\ssms.sql.12.0\Shell\Open\Command]
@="\C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\ssms.exe\ \%1\ /dde"