Friday, June 5, 2020

Using Azure Data Studio with SQL Prompt

One of the coolest and most useful features of Azure Data Studio (ADS) is SQL Notebooks. If you haven’t seen them, notebooks allow you to combine text with markdown and runnable code in the same document, and they are shareable. Notebooks might be used for teaching, documentation, or runbooks among other uses.

I recently heard about a public preview for Redgate’s SQL Prompt for ADS, and I wondered if the features would work only in a query window or if the features would also work in a notebook. After testing, I found that yes, SQL Prompt features do work in notebooks. It doesn’t matter if you are working in a query window or a notebook, you can take advantage of SQL Prompt!

To try it out, I installed the most recent ADS version and the public preview for SQL Prompt for ADS. The first feature I tested was formatting.

Formatting

There is some built-in formatting in ADS, but there is just one style. SQL Prompt has several built-in styles, plus it imports styles from SSMS if you have it installed and allows you to create your own custom styles.

You must tell ADS that you want to use SQL Prompt for formatting either for the current operation or as a default. To set it up as the default, right-click in a notebook code cell or in the query window. Then select Format Document With as shown in Figure 1.

Figure 1: Choose a formatter

A dialog will pop up. Click Configure Default Formatter as shown in Figure 2.

Figure 2: Configure the default

Then click Redgate SQL Prompt as shown in Figure 3.

Figure 3: Select SQL Prompt

From then on, SQL Prompt will be the default formatting tool for both the notebooks and query window.

One advantage of SQL Prompt is that you have several formats from which to choose. There are five built-in formatting styles and any created in SSMS will automatically import. To see the styles, first bring up the command pallet by typing CTRL+SHIFT+P. You can search for everything related to Prompt as shown in Figure 4. Select SQL Prompt: Change Active Formatting Style.

Figure 4: Find Change Active Formatting Style

Here you’ll see a list of built-in styles plus any of your custom styles shown in Figure 5. You can select any of them to be your default style going forward.

Figure 5: Select a formatting style

Notice in Figure 4 that you can also delete, create, or edit formatting styles. Now, formatting the way you like it is just a right-click away in both notebooks and the query window.

Another feature available in this preview is the well-loved snippets. Learn about that next!

Snippets

Snippets save SQL Prompt users tons of time. They are as simple as typing in three or four characters to get anything from a SELECT statement to a function definition. Just like formatting, this feature can be seen in the notebooks. Figure 6 shows the famous SSF (select star from) snippet.

Figure 6: Select star from

Snippets are great for things that you type often, like the team’s official comment section for procs. To see the available snippets, go to the command pallet and search for Preferences: Configure User Snippets as shown in Figure 7.

Figure 7: Configure user snippets

You’ll be able to see your custom snippet list and create your own.

Conclusion

SQL Prompt is a popular tool that has worked in SSMS and Visual Studio to save you time writing T-SQL code. Now, there is a preview of SQL Prompt that runs in Azure Data Studio, and you get these features in both query windows and notebooks!

 

The post Using Azure Data Studio with SQL Prompt appeared first on Simple Talk.



from Simple Talk https://ift.tt/2Mqwx0W
via

No comments:

Post a Comment