Azure Data Studio Snippets #17

I know snippets have been around for years and I have utilised lots of SSMS tools like ssmstoolspack back in the day persuading a company I worked for to buy a copy for the developers.  Of late my SSMS tool of choice is ssmsboost, even buying it my self personally, well my company which is more or less the same, they also have a free community version for people involved in the community and they have helped out with Sponsorship several times for Manchester SQL Saturday and Manchester DataPlatform events.

I never really bought into snippets however till I started using Azure Data Studio and wow, so much productivity.

The first thing is to install the Query Editor Boost extension which has several features but the one this post is about is to easily add in snippets

09 Snippets Nothing better than showing by example in several easy steps. This came from trying to write a query without knowing the schema in the database, I know I’ll create a snippet.

1) Ctrl-N for a new SQL file

2) Paste in the code you want to make a snippet of

FROM sys.schemas
        , ‘db_accessadmin’
        , ‘db_securityadmin’
        , ‘db_ddladmin’
        , ‘db_backupoperator’
        , ‘db_datareader’
        , ‘db_datawriter’
        , ‘db_denydatareader’
        , ‘db_denydatawriter’
3) Open up the menu Ctrl-Shift+P and type in QE and choose Save New Query Template
13 New snippet
4) Enter a Name for the snippet
14 sqlSchema
5) Enter a prefix – I tend to keep the same name it’s easier
15 sqlSchema
6) Give the snippet a description
16 schema description
Now when you type sql you get a list of snippets and the description
17 snippets in action
hitting return you get the SQL script pasted in.
These are all stored in a text file in a JSON format in the following location, so you can build a library and take it with you.
I am now going through a process of adding in my useful scripts into snippets. It takes literally seconds once you have the SQL.
I’ll add in a post with a link to my snippets file and the code snippets I have.
This entry was posted in Azure Data Studio, Azure Data Studio Extensions, Management Studio, Productivity, Snippets, Uncategorized. Bookmark the permalink.

Leave a Reply

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

You are commenting using your 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 )

Connecting to %s