Code Snippets in Azure Data Studio

Azure Data Studio has a feature called Code Snippets which allow you to quickly create all of those commands that you forget the syntax for all the time.

Crack open a new query window and type in ‘sql’, you’ll see all of the default templates

Choose any to look at and you’ll see a template with fields for you to change. sqlAddColumn looks like this

It gives you the fields to replace with your own query along with comments explaining what each section is for. Really handy.

It even has complicated stuff like cursors off the bat

Tell me you’d remember the syntax for a cursor without looking it up, I certainly wouldn’t.

A great thing about these snippets is that you can add your own and they can be exactly how you want them.

To get started with this open the Command Pallet with Ctrl+Shift+P and type in ‘snippets’.

Scroll down and find the SQL option. Open it and it will bring you to the SQL.json file in which we’ll be storing our SQL Snippets.

Here’s an example of where to start.

Paste this into your file. Close the sql.json file and save your results then open a new query window (Ctrl+N). Type in ‘sql’ and you’ll see the two new snippets that you created

And there you go, you’ve got custom snippets waiting for you. You can go ahead and create whatever you’d like in whatever format you like.

These snippets are based on Visual Studio Code, for the official documentation head here.

Happy snipping!

WP Twitter Auto Publish Powered By :
%d bloggers like this: