{"id":87340,"date":"2020-06-04T18:23:53","date_gmt":"2020-06-04T18:23:53","guid":{"rendered":"https:\/\/www.red-gate.com\/simple-talk\/?p=87340"},"modified":"2020-06-04T18:23:53","modified_gmt":"2020-06-04T18:23:53","slug":"using-azure-data-studio-with-sql-prompt","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/blogs\/using-azure-data-studio-with-sql-prompt\/","title":{"rendered":"Using Azure Data Studio with SQL Prompt"},"content":{"rendered":"<p>One of the coolest and most useful features of Azure Data Studio (ADS) is SQL Notebooks. If you haven\u2019t 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.<\/p>\n<p>I recently heard about a public preview for Redgate\u2019s 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\u2019t matter if you are working in a query window or a notebook, you can take advantage of SQL Prompt!<\/p>\n<p>To try it out, I installed the most recent <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/azure-data-studio\/download-azure-data-studio?view=sql-server-ver15\">ADS version<\/a> and the public preview for <a href=\"https:\/\/download.red-gate.com\/EAP\/SQLPromptADS.zip\">SQL Prompt for ADS<\/a>. The first feature I tested was formatting.<\/p>\n<h2>Formatting<\/h2>\n<p>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.<\/p>\n<p>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 <em>Format Document With<\/em> as shown in Figure 1.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"913\" height=\"472\" class=\"wp-image-87341\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2020\/06\/word-image-5.png\" \/><\/p>\n<p><strong>Figure 1: Choose a formatter<\/strong><\/p>\n<p>A dialog will pop up. Click <em>Configure Default Formatter<\/em> as shown in Figure 2.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"989\" height=\"329\" class=\"wp-image-87342\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2020\/06\/word-image-6.png\" \/><\/p>\n<p><strong>Figure 2: Configure the default<\/strong><\/p>\n<p>Then click <em>Redgate SQL Prompt <\/em>as shown in Figure 3.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1013\" height=\"314\" class=\"wp-image-87343\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2020\/06\/word-image-7.png\" \/><\/p>\n<p><strong>Figure 3: Select SQL Prompt<\/strong><\/p>\n<p>From then on, SQL Prompt will be the default formatting tool for both the notebooks and query window.<\/p>\n<p>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 <em>SQL Prompt: Change Active Formatting Style.<\/em><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"955\" height=\"353\" class=\"wp-image-87344\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2020\/06\/word-image-8.png\" \/><\/p>\n<p><strong>Figure 4: Find Change Active Formatting Style<\/strong><\/p>\n<p>Here you\u2019ll 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.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"501\" height=\"289\" class=\"wp-image-87345\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2020\/06\/word-image-9.png\" \/><\/p>\n<p><strong>Figure 5: Select a formatting style<\/strong><\/p>\n<p>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.<\/p>\n<p>Another feature available in this preview is the well-loved snippets. Learn about that next!<\/p>\n<h2>Snippets<\/h2>\n<p>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.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"608\" height=\"340\" class=\"wp-image-87346\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2020\/06\/word-image-10.png\" \/><\/p>\n<p>Figure 6: Select star from<\/p>\n<p>Snippets are great for things that you type often, like the team\u2019s 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.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"340\" height=\"83\" class=\"wp-image-87347\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2020\/06\/word-image-11.png\" \/><\/p>\n<p>Figure 7: Configure user snippets<\/p>\n<p>You\u2019ll be able to see your custom snippet list and create your own.<\/p>\n<h2>Conclusion<\/h2>\n<p>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!<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the coolest and most useful features of Azure Data Studio (ADS) is SQL Notebooks. If you haven\u2019t 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&#8230;&hellip;<\/p>\n","protected":false},"author":110218,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[5134],"coauthors":[11292],"class_list":["post-87340","post","type-post","status-publish","format-standard","hentry","category-blogs","tag-sql-prompt"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/87340","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/110218"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=87340"}],"version-history":[{"count":3,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/87340\/revisions"}],"predecessor-version":[{"id":87350,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/87340\/revisions\/87350"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=87340"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=87340"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=87340"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=87340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}