The 'SELECT' Few: Enhancing SSMS with SQL Add-Ons and tweaks
Tags: sql, ssms, database, dbms
Published: 2023-11-28 13:22:23

So, the first programming course being over, we have now moved over from C# to SQL, leaving Visual Studio for SSMS. At least for a couple of weeks. I had not worked with databases before, at least not that way. I had mostly used database tables within cartography adn geodata analysis to retrieve and display data graphically but using a query builder and not real SQL queries.

I find it quite fun and relatively intuitive. Most often satisfying. SQL is not a difficult language per say but sometimes feels like it was made up by a programmer who kinda sucked and thought they could make it more natural to write, which, somehow, it is. I guess it feels that way because it's been around since the 1970s, which is, all in all, pretty impressive. This is all a joke, SQL is a powerful language that will let you filter and display anything you want.

I am enjoying it but some formatting conventions and best practices can be quite tedious and not very easy on your fingers, should you choose to follow them. For instance, capitalization of keywords. Of course, you're free to ignore them but I like to follow these conventions to make the code more readable and easier to understand. However, it kinda hurts after a while, having to hold <kbd>shift</kbd> for full words or expressions, or having to enable/disable <kbd>caps</kbd> all the time. Also, I'm lazy.

## SQL Complete
I have spent quite some time researching possible settings,  add-ons or tricks, and they are many, but mostly behing paywalls and some of them would have you sell a kidney on the darknet to be able to finance, especially as a poor student. But I am not easily defeated when it comes to be lazy, si I persevered and found dbForge's *SQL Complete* add-on for SSMS, which lets you tweak the formatting of your SQL code. You can for example choose to automatically enclose identifiers within square brackets (and even choose conditions for this). You can also use existing formatting profiles, provided by SQL Complete or use them as templates to create your own formatting profile, saved as an xml document om your machine, should you want to use it across different machines. Within these profile, you are able to edit any formatting for any command (tabs, line breaks before and after, size of tabs, etc.). The possibilities are pretty much infinite. Not actually, but I swear you'll find what you need. 

![Screenshot of formatting profile](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l56cy6qbnpati98tu8ns.png)

Oh and I almost forgot, you can even ask it to format whole folders with `.sql` files on your computer. I know...

What more to ask? Well, on top of that, it's free. The Express version of SQL Complete is completely free. Upon download and set up, you'll get a Trial of their premium version first and it will downgrade to Express when the trial expires. You will lose some functionality after that but most of the formating settings will remain. Even if for a couple of weeks, it is very worth the try.
You can get it [here](https://www.devart.com/dbforge/sql/sqlcomplete/editions.html).

## Use your favorite VS Code theme in SSMS
This great [Github repository](https://github.com/tcartwright/SSMSThemeEditor) by [Tim Cartwright](https://github.com/tcartwright) will take you through the steps of customizing your SSMS theme, because let's face it, the default theme is very bad, both for the eyes and the soul. It is very surprising that Microsoft hasn't made it possible to customize it or implemented a real dark mode into SSMS. 

You can follow the instructions on this repo to the letter or you can mix them with a few other processes to get SSMS to look exactly like you want, which I did. 

My all time favorite VS Code theme is [_Monokai Drake_](https://marketplace.visualstudio.com/items?itemName=lakshits11.monokai-drake) and I use it for absolutely everything, VS Code, Visual Studio, Obsidian and now SSMS. To get any VS Code theme to work in SSMS, you need to convert it into a `.pkgdef`. Easy, right? Well, actually not so hard thanks to [this tutorial](https://github.com/microsoft/theme-converter-for-vs#getting-a-themes-json-file). Follow the instructions: start by creating the theme's `.JSON` file and then go back to _Using the tool_. At step 6, choose the second option. If you want to use your favorite theme in Visual Studio too, keep following the instructions on how to create a `.vsix` file. 

Once you have the `.pkgdef` file, go back to the _[VS Color Themes](https://github.com/tcartwright/SSMSThemeEditor/wiki/How-Do-I-install-Custom-Color-Themes-for-SSMS%3F)_ tutorial and follow the instructions to install the theme manually. Basically, go to wherever SSMS is installed on your computer, by default `C:\Program Files (x86)\Microsoft SQL Server Management Studio 19\Common7\IDE\Extensions`, create a `VSColorThemes` folder and paste the `.pkgdef` file you created earlier. Launch SSMS and change the theme. Voilà! Note that the _Object Explorer_ and _Results_ window will remain white and you'll have to live with it.
Mine looks like this:

![SSMS with custom theme](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5d5iytgacca64plelnk2.jpg) 

## SQL Shades
If you can't live with it, forget using a custom theme and use _[SQL Shades](https://www.sqlshades.com/)_ instead. The colors are not customizable in its current version, but the whole program will be in dark mode. Of course, it's free! 

That's all for now, hope your SQL life will be smoother with these tips!