views:

1250

answers:

7

When I go to File > Open > File and select a .sql script, or even when I drag a .sql file into the SQL Management Studio Express window, it opens the script in Notepad which is totally useless when I want to run the script.

Since this is on an external server (Windows 2003 Server), I end up having to disconnect from RDP, disable the local clipboard, re-connect and then copy-paste the script's contents from Textpad in order to run it.

I've checked the options menus but can't see anything relating to Notepad, not even in the "external tools" section. Any ideas why it would be doing this?

Please note: I have checked the file association for SQL scripts and it is set to SQL Management Studio Express.

A: 

The first thing I'd check is to see if the application associated with SQL files on that box is Notepad.

Stephen Wrighton
A: 

UPDATE:

In SQL Management Studio,

Go to File > Open > File,  
Highlight a SQL file,  
Click the down arrow on the Open button.   
Select Open With... 
Select SQL Query Editor 
Press the Set as Default button.

Matt

Lima
No dice - file type 'SQL' is associated with "SQLWB - SQL Server Management Studio".
tags2k
Does my update above work for you?
Lima
A: 

What does Windows open .sql files with? (File Types tab in Folder options)

StuperUser
A: 

Have you tried changing the file type in Windows Exporer?

  • Open up Windows Explorer
  • Click on the Tools menu, then select 'Folder Options...'
  • Click on the Files Types Tab
  • Navigate to the SQL File type and change it to Management Studio.
kevchadders
A: 

Ran into this this morning. Turned out to be an encoding issue for me. I opened the script up in UltraEdit and I noticed that it was showing the encoding to be U-DOS instead of DOS. I ran the Unicode to ASCII conversion (also in UltraEdit), saved the file, and now Management Studio is opening up the files correctly.

NFrank
How does this work with nvarchar or ntext content? Some of my scripts contain "foreign" languages, so converting to ANSI isn't going to help.
tags2k
A: 

I encountered this too - thanks NFrank for spotting the issue:

This was caused by opening the script in TextPad and accidentally saving as Unicode. The issue is not related to file associations.

The solution: Open in Notepad (or TextPad) - Save As... and select Encoding: ANSI

MuppetLabs
A: 

Unicode to ANSI fixed it for me (as described in the other solutions here).

Brandon