Microsoft supports SQL Notebooks in Azure Data Studio. It is an exciting feature that allows creating a notebook for multiple languages such as Python, SQL, PowerShell. You might have heard about the Jupyter notebook. It is a popular web-based notebook that provides rich programming language support. SQL Notebook is an inspiration for the Jupyter notebook.
To follow along nicely, I would recommend going through the below articles:
- SQL Notebooks introduction and overview
- A handy SQL Notebook for troubleshooting in Azure Data Studio
- Use Python SQL scripts in SQL Notebooks of Azure Data Studio
You should also use the latest version of Azure Data Studio.
- Latest version: 1.15.0
- Release date: February 15, 2020
- Download: Microsoft
Download the installer per the platform: Windows, macOS or Linux.
Overview of Markdown language
SQL Notebooks uses markdown language for text formatting. If you are familiar with GitHub, it uses markdown language for all forms such as read me file. We can do text formatting with its simplified method. It helps us to write easy-to-read, easy-to-write plain text with structurally valid XHTML.
HTML is a popular programming language. We use tags in HTML for defining text into various formats. For example, for a H1 heading, we use <h1>Title</h1> tags.
Launch Azure Data Studio and open a SQL notebook.
It opens a blank notebook, as shown below.
The first step for a document is heading. We also require heading for different sections in the article. We want a different size for the headings and subheadings.
We use hash sign (#) preceding with the text and the number of # defines the heading font level. It supports up to six levels of headings.
You can view difference in these heading font size in the following image.
# SQL Notebook
## SQL Notebook
### SQL Notebook
#### SQL Notebook
##### SQL Notebook
###### SQL Notebook
We can also use the following markdown code for first and second-level headings.
We write documents in many paragraphs. To specify a paragraph in the markdown language, leave an empty line. In the following example, we give an empty line after Hello but did not give any empty line after team. In the output, markdown language understands an empty line at the end of the paragraph. It treats the last two lines as a single paragraph.
Format Bold text
We can enclose the text in double star( **), and it highlights text in bold format.
Format Italic text
Enclose the text in single star(*) and it changes the format for text in italic.
Format Bold and Italic text
We can combine both bold and italic format for text by enclosing text with three starts ***
Create bullet lists in the notebook
You might be familiar with creating bullet lists in Microsoft Word document. We can create similar lists using markdown language.
Use prefix * followed by a space for the unordered lists. We can also create a nested list using this prefix.
In the above image, feature 1 and feature 2 are at the same level. Due to this, in markdown, we get a similar bullet for both.
We can create a further nested list by changing the position of the text, as shown below.
The ordered list shows the sequence number for each line. We specify a number for each line, and it creates an ordered list.
We can easily configure both ordered and unordered list combining both stars (*) and numbers as shown below
We can add a word as a code format by enclosing it in backticks (`).
We can add a greater than(>) symbol in beginning of a paragraph, and it turns into a blockquote element.
To add multiple lines in the same blockquote, add > in each line.
Sometimes you require nested blockquotes as well. We can add >> for the nested blockquotes as shown below.
Specifying URL hyperlink
Sometimes, we include hyperlinks in a document as well so that users can click on the hyperlink and go to the reference website.
We can create both inline and reference style links using the markdown language.
Inline hyperlinks are similar to a word document hyperlink. We specify it in the following format.
[Text to display] (URL)
Reference Style Links
We can also create a referenced style links in markdown language. Suppose we want to use the same URL hyperlink in multiple places like reference articles from Microsoft Word. We can either create an inline hyperlink each time or use a reference style hyperlink.
In the following example, we specify [Link 1] text multiple time and later referenced that text for the URL. It saves efforts for us to specify inline hyperlink and users can also know that all these references are from a single URL. You can see these reference style hyperlink on a website like Wikipedia.
We can reference an image using an exclamation mark (!) symbol and add an alt-text in the square brackets along with the image URL. In the following example, we can see the Wikipedia logo in SQL Notebook using markdown language.
We can also create a reference style image reference in the markdown similar to the reference URL. For this, we can use the below format.
[logo]: https://upload.wikimedia.org/wikipedia/en/8/80/Wikipedia-logo-v2.svg “Wikipedia”
Add Horizontal Rule
We can create a horizontal rule by enclosing text *** symbol(three or more) followed by a line break. You can see a horizontal rule in the below image.
Specify email in the text
We can enclose email address in <> symbol so that it appears as a hyperlink in the output.
As I explained earlier, we use * for an unordered list. Suppose we want to print this character as well in the output. In this case, add a backslash to skip the behavior of * in markdown language.
Add Tables in a notebook
Markdown does not specify code for tables, but still, we can create them.
- We use colons to align the columns
- We require at least three dashes to separate column headers
- We can use outer pips for separating columns
Here is the markup code for an employee table with three columns- EmployeeName, Location and designation.
| EmployeeName | Location | Designation |
| ————- |:————-:| —–:|
| Rajendra Gupta | India | Sr. Consultant |
| Kusum Agarwal | India | Physiotherapist |
| Akshita Gupta | India | Intern |
Add Videos in the notebook
We do not have a direct method to add a video link in the markdown language. But, there is always a workaround.
Follow the below steps to add a video reference in SQL notebook.
- Extract a thumbnail of the video you wish to create a reference. You can either take a screenshot of the video or use third-party tools for the thumbnail of it
- Create a reference link for the video
For this demonstration, I am using the YouTube video link and using an image for thumbnail purposes.
[![SQL Server 2019](C:\Users\rajen_000\Pictures\SQL2019.JPG)](http://www.youtube.com/watch?v=mKlAyvvR70I “SQL 2019”)
It renders an image, as shown below.
Click on the image, and it asks your permission to open the external Website.
Click open, and it plays the YouTube video in the browser.
In this article, we explored markdown language to do formatting in a SQL Notebook of Azure Data Studio. I have covered most of the formatting options, and you can combine those for preparing a handbook with better visualization and useful pieces of information.
- Azure Analysis Services and Power BI Live connections - April 14, 2021
- An overview of Power BI data models - April 12, 2021
- Capturing deadlocks on AWS RDS SQL Server databases - April 7, 2021