SQL Code Highlighting in Visual Studio

This is something I’ve been trying to do for a while and finally found the solution in a forum post (. The post is very succinct so I’ll expand on it a little more here.

I am working with .SqlDataProvider files which are basically T-SQL scripts to create data tables, stored procedures and other db objects. When you open a file like this in Visual Studio, you get no syntax highlighting at all. There is an option to associate file extensions to editors within VS but none of them allow you to match an extension with the SQL editor. The only way to do this is by a little registry hack.

Here is how it’s done so you can repeat it for any other language type:

1. Open the registry editor (regedit.exe)
Note: if you don’t feel comfortable with editing the registry, I’d suggest that you stop right there and deal with the non-highlighted text

2. Go to
————Language Services
where version is the version number for your Visual Studio (8.0 for VS 2005 and 9.0 for VS 2008)

3. When you expand the Language Services key, you get a list of languages supported by VS. The one we are interested in is T-SQL90. Expand this key and copy the string value called (Default). For T-SQL90, the value is {43AF1158-FED5-432e-8E8F-23B6FD592857}

4. Now, go to
————File Extensions

5. Create a new key with the name of your extension including the dot. In our example the key name will be .sqldataprovider

6. In the newly created key, paste the value that we previously copied in the (Default) String Value. You can also define a name for the extension by creating a new String Value called Name and setting it to any name you want

You can now close the registry editor, restart your Visual Studio and voila, your SQL code is highlighted

Reference: Thank you Neolithos for this solution – http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/9187dc75-fc05-4872-bfc1-1fdbff590df2/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: