>> Hi my name is Alan Yu,
a Program Manager on the SQL Server team.
In today's how to video,
I'll be covering a Notebook viewer in Azure Data Studio,
creating your first SQL Notebook,
and how to interact with and use your SQL Notebook.
Notebooks are single documents that comprise
of rich text cells like
Markdown and executable code cells like Python.
Notebooks can also include visualizations,
code output, and even GIFs.
Notebooks are a very popular tool in
the data scientist community for use cases,
such as interactive tutorials,
running daily analysis, or telling stories using data models.
Azure Data Studio supports Notebooks,
including a special kernel known as the SQL Kernel.
With the SQL Kernel,
you can now create Custom Notebooks using
both T-SQL or PostgresSQL.
Let's start off with our SQL Notebook toolbar.
As you can see, you can easily add a code cell or
a text cell and then quickly be
able to write things and see the preview of it,
and then you can also delete your cell.
As mentioned before, we have the
special SQL Kernel using this Notebook,
but you can also easily change it if you wanted to have
a Python Notebook or Spark Notebook, etc.
Next, you see this component called,
"Attach To" and this is where you actually make a connection
to your SQL Server instance
where your Notebook will be run against.
So for now, I'm running a version of SQL Server 2017 locally.
Next, we're able to make sure that our Notebook is trusted,
have the ability to run all the code cells if a Notebook,
and then also be able to clear all the output from
those code cells easily from a click of a button.
So for the purposes of this tutorial,
we'll be looking at
this tutorial from our official SQL Server Docs,
where you can create and query
database objects and essentially learn how to write T-SQL.
This is a very important use case of Notebooks where you can
help educate people of how to get started on your team,
or just generally learned about SQL itself.
So what we're going to do here is
essentially copy over this tutorial,
which I have here in Visual Studio code.
So I'm going to copy over
the text component which is written in Markdown,
and I'm going to add a text cell.
So as you can see here, several things appear.
So to start off, Markdown is
a rich text language for converting text to HTML.
There are many resources online to learn more about Markdown,
but for now I'll show some of the components of a text cell.
So for example, one of the components of Markdown is that,
if you add a pound sign this indicates that is the header,
and you can see that there's a preview as you type
here and it will automatically show in the information below.
So it's easily you can tell what is the output of your Markdown.
So after you are comfortable with
providing the instructions at the top of your Notebook,
you can next add a code cell by clicking
this button here or the toolbar as mentioned before.
So I'm going to add a code cell,
and essentially this will run
a T-SQL command for creating your database.
Then if I want to execute this cell right now,
I could click the "Play" button to run the cell.
So I can continue this process of combination of text cells
and adding code cells in
a repeated pattern but the save all of us time,
I already created this Notebook before and we
can now use this to explore what exactly this tutorial includes.
So you can see that it starts off by creating
a table, creating a database,
and this tells you how to get started with creating a database,
and then it will eventually go down to
inserting actual data into your table,
and then eventually being able to select that values as well.
So for this Notebook,
actually is okay that we already run all the cells at
once so then we could go around and play with the tutorial itself.
So in order to execute all the code cells,
you could click "Run Cells" here,
and then the Notebook will just start running
all the code cells and generate output for it.
So for example, you see there is a select statement here
and you can see that the output is
nicely printed out from our results grid.
In fact, if you wanted to share this data in another format,
you can "Right-click" on it and then
"Save" it in these very common formats,
such as a CSV, and we'll save it really quick here.
You can see that you will get the same results on
a CSV file or for the other supported file types.
So in addition, if you wanted to rerun the cell,
to make sure that like any changes to the database occurred,
you can rerun it and you can
confirm that all the data still is the same.
So there's a lot of use cases that you could
do with creating your own SQL Notebooks.
Not only can you be using this to help educate people and have
a step-by-step process as they walked through the tutorial,
we can also imagine using this for running
daily jobs and just have all the basic configuration
in there and then include Markdown instructions so that you can
easily understand when to execute these different pieces of T-SQL.
So there's a lot of fun things you can do with Notebooks.
This will just help you get
started with creating your very first one.
So in order to help you get
started with creating SQL Notebooks after this video,
I've created these awesome next steps for you.
You could first start off by downloading
Azure Data Studio at aka.ms/getazuredatastudio.
You can also visit our Docs,
where we have specific documentation explaining
a lot of the concepts that I talked about in this video,
and then follow us on Twitter for any of
the latest updates as we continue
to grow this feature and Notebook itself.
Please try out SQL Notebooks today.
Thank you
[MUSIC].