WEBVTT

00:00:09.530 --> 00:00:12.195
>> Hi my name is Alan Yu,

00:00:12.195 --> 00:00:15.180
a Program Manager on
the SQL Server team.

00:00:15.180 --> 00:00:17.745
In today's how to video,

00:00:17.745 --> 00:00:20.835
I'll be covering a Notebook
viewer in Azure Data Studio,

00:00:20.835 --> 00:00:22.710
creating your first SQL Notebook,

00:00:22.710 --> 00:00:26.860
and how to interact with
and use your SQL Notebook.

00:00:26.870 --> 00:00:30.315
Notebooks are single
documents that comprise

00:00:30.315 --> 00:00:31.830
of rich text cells like

00:00:31.830 --> 00:00:35.130
Markdown and executable
code cells like Python.

00:00:35.130 --> 00:00:37.960
Notebooks can also
include visualizations,

00:00:37.960 --> 00:00:40.100
code output, and even GIFs.

00:00:40.100 --> 00:00:42.710
Notebooks are a very popular tool in

00:00:42.710 --> 00:00:45.350
the data scientist
community for use cases,

00:00:45.350 --> 00:00:47.135
such as interactive tutorials,

00:00:47.135 --> 00:00:51.365
running daily analysis, or telling
stories using data models.

00:00:51.365 --> 00:00:54.470
Azure Data Studio supports Notebooks,

00:00:54.470 --> 00:00:57.815
including a special kernel
known as the SQL Kernel.

00:00:57.815 --> 00:00:59.270
With the SQL Kernel,

00:00:59.270 --> 00:01:01.520
you can now create
Custom Notebooks using

00:01:01.520 --> 00:01:04.390
both T-SQL or PostgresSQL.

00:01:04.390 --> 00:01:07.485
Let's start off with our
SQL Notebook toolbar.

00:01:07.485 --> 00:01:10.670
As you can see, you can
easily add a code cell or

00:01:10.670 --> 00:01:12.770
a text cell and then quickly be

00:01:12.770 --> 00:01:15.065
able to write things and
see the preview of it,

00:01:15.065 --> 00:01:17.665
and then you can also
delete your cell.

00:01:17.665 --> 00:01:19.860
As mentioned before, we have the

00:01:19.860 --> 00:01:22.820
special SQL Kernel
using this Notebook,

00:01:22.820 --> 00:01:25.510
but you can also easily change
it if you wanted to have

00:01:25.510 --> 00:01:28.700
a Python Notebook or
Spark Notebook, etc.

00:01:28.700 --> 00:01:30.960
Next, you see this component called,

00:01:30.960 --> 00:01:33.970
"Attach To" and this is where
you actually make a connection

00:01:33.970 --> 00:01:36.340
to your SQL Server instance

00:01:36.340 --> 00:01:38.005
where your Notebook
will be run against.

00:01:38.005 --> 00:01:43.175
So for now, I'm running a version
of SQL Server 2017 locally.

00:01:43.175 --> 00:01:46.705
Next, we're able to make sure
that our Notebook is trusted,

00:01:46.705 --> 00:01:50.470
have the ability to run all
the code cells if a Notebook,

00:01:50.470 --> 00:01:52.570
and then also be able to
clear all the output from

00:01:52.570 --> 00:01:55.435
those code cells easily
from a click of a button.

00:01:55.435 --> 00:01:59.035
So for the purposes of this tutorial,

00:01:59.035 --> 00:02:01.465
we'll be looking at

00:02:01.465 --> 00:02:05.210
this tutorial from our
official SQL Server Docs,

00:02:05.210 --> 00:02:06.560
where you can create and query

00:02:06.560 --> 00:02:09.980
database objects and essentially
learn how to write T-SQL.

00:02:09.980 --> 00:02:13.760
This is a very important use
case of Notebooks where you can

00:02:13.760 --> 00:02:17.660
help educate people of how
to get started on your team,

00:02:17.660 --> 00:02:21.475
or just generally learned
about SQL itself.

00:02:21.475 --> 00:02:23.360
So what we're going to do here is

00:02:23.360 --> 00:02:25.100
essentially copy over this tutorial,

00:02:25.100 --> 00:02:28.595
which I have here in
Visual Studio code.

00:02:28.595 --> 00:02:30.050
So I'm going to copy over

00:02:30.050 --> 00:02:32.845
the text component which
is written in Markdown,

00:02:32.845 --> 00:02:34.925
and I'm going to add a text cell.

00:02:34.925 --> 00:02:37.295
So as you can see here,
several things appear.

00:02:37.295 --> 00:02:39.230
So to start off, Markdown is

00:02:39.230 --> 00:02:42.575
a rich text language for
converting text to HTML.

00:02:42.575 --> 00:02:46.130
There are many resources online
to learn more about Markdown,

00:02:46.130 --> 00:02:48.935
but for now I'll show some of
the components of a text cell.

00:02:48.935 --> 00:02:52.070
So for example, one of the
components of Markdown is that,

00:02:52.070 --> 00:02:55.070
if you add a pound sign this
indicates that is the header,

00:02:55.070 --> 00:02:57.560
and you can see that there's
a preview as you type

00:02:57.560 --> 00:03:01.460
here and it will automatically
show in the information below.

00:03:01.460 --> 00:03:07.100
So it's easily you can tell what
is the output of your Markdown.

00:03:07.100 --> 00:03:09.605
So after you are comfortable with

00:03:09.605 --> 00:03:12.065
providing the instructions
at the top of your Notebook,

00:03:12.065 --> 00:03:14.690
you can next add a
code cell by clicking

00:03:14.690 --> 00:03:17.630
this button here or the
toolbar as mentioned before.

00:03:17.630 --> 00:03:19.880
So I'm going to add a code cell,

00:03:19.880 --> 00:03:22.500
and essentially this will run

00:03:22.500 --> 00:03:25.035
a T-SQL command for
creating your database.

00:03:25.035 --> 00:03:27.635
Then if I want to execute
this cell right now,

00:03:27.635 --> 00:03:29.840
I could click the "Play"
button to run the cell.

00:03:29.840 --> 00:03:34.250
So I can continue this process
of combination of text cells

00:03:34.250 --> 00:03:35.750
and adding code cells in

00:03:35.750 --> 00:03:38.600
a repeated pattern but
the save all of us time,

00:03:38.600 --> 00:03:41.990
I already created this
Notebook before and we

00:03:41.990 --> 00:03:45.740
can now use this to explore what
exactly this tutorial includes.

00:03:45.740 --> 00:03:47.870
So you can see that it
starts off by creating

00:03:47.870 --> 00:03:51.290
a table, creating a database,

00:03:51.290 --> 00:03:55.775
and this tells you how to get
started with creating a database,

00:03:55.775 --> 00:03:57.890
and then it will
eventually go down to

00:03:57.890 --> 00:04:00.770
inserting actual data
into your table,

00:04:00.770 --> 00:04:04.845
and then eventually being able
to select that values as well.

00:04:04.845 --> 00:04:06.825
So for this Notebook,

00:04:06.825 --> 00:04:09.620
actually is okay that we
already run all the cells at

00:04:09.620 --> 00:04:13.085
once so then we could go around
and play with the tutorial itself.

00:04:13.085 --> 00:04:15.665
So in order to execute
all the code cells,

00:04:15.665 --> 00:04:17.470
you could click "Run Cells" here,

00:04:17.470 --> 00:04:19.865
and then the Notebook
will just start running

00:04:19.865 --> 00:04:23.170
all the code cells and
generate output for it.

00:04:23.170 --> 00:04:26.300
So for example, you see there
is a select statement here

00:04:26.300 --> 00:04:28.130
and you can see that the output is

00:04:28.130 --> 00:04:30.580
nicely printed out
from our results grid.

00:04:30.580 --> 00:04:34.415
In fact, if you wanted to share
this data in another format,

00:04:34.415 --> 00:04:35.990
you can "Right-click" on it and then

00:04:35.990 --> 00:04:38.210
"Save" it in these
very common formats,

00:04:38.210 --> 00:04:42.210
such as a CSV, and we'll
save it really quick here.

00:04:42.210 --> 00:04:44.780
You can see that you will
get the same results on

00:04:44.780 --> 00:04:48.995
a CSV file or for the other
supported file types.

00:04:48.995 --> 00:04:51.665
So in addition, if you
wanted to rerun the cell,

00:04:51.665 --> 00:04:56.390
to make sure that like any
changes to the database occurred,

00:04:56.390 --> 00:04:58.070
you can rerun it and you can

00:04:58.070 --> 00:05:00.770
confirm that all the
data still is the same.

00:05:00.770 --> 00:05:02.840
So there's a lot of use
cases that you could

00:05:02.840 --> 00:05:05.150
do with creating your
own SQL Notebooks.

00:05:05.150 --> 00:05:08.330
Not only can you be using this
to help educate people and have

00:05:08.330 --> 00:05:11.734
a step-by-step process as they
walked through the tutorial,

00:05:11.734 --> 00:05:14.450
we can also imagine
using this for running

00:05:14.450 --> 00:05:17.060
daily jobs and just have
all the basic configuration

00:05:17.060 --> 00:05:20.780
in there and then include Markdown
instructions so that you can

00:05:20.780 --> 00:05:26.270
easily understand when to execute
these different pieces of T-SQL.

00:05:26.270 --> 00:05:29.395
So there's a lot of fun things
you can do with Notebooks.

00:05:29.395 --> 00:05:31.160
This will just help you get

00:05:31.160 --> 00:05:33.485
started with creating
your very first one.

00:05:33.485 --> 00:05:36.230
So in order to help you get

00:05:36.230 --> 00:05:39.500
started with creating SQL
Notebooks after this video,

00:05:39.500 --> 00:05:43.140
I've created these awesome
next steps for you.

00:05:43.140 --> 00:05:45.410
You could first start
off by downloading

00:05:45.410 --> 00:05:48.310
Azure Data Studio at
aka.ms/getazuredatastudio.

00:05:48.310 --> 00:05:50.790
You can also visit our Docs,

00:05:50.790 --> 00:05:53.240
where we have specific
documentation explaining

00:05:53.240 --> 00:05:55.970
a lot of the concepts that I
talked about in this video,

00:05:55.970 --> 00:05:57.620
and then follow us on
Twitter for any of

00:05:57.620 --> 00:05:59.360
the latest updates as we continue

00:05:59.360 --> 00:06:02.950
to grow this feature
and Notebook itself.

00:06:02.950 --> 00:06:04.890
Please try out SQL Notebooks today.

00:06:04.890 --> 00:06:05.520
Thank you

00:06:05.520 --> 00:06:20.320
[MUSIC].

