{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"
\n",
"\n",
"## SQL Notebooks in Azure Data Studio\n",
"\n",
"Notebooks allow rich text, images, code, and resultsets to be easily shared. This is a concept that is widely used in data science and which we feel is well suited to SQL work. \n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"select \n",
" 'Hello SQL World' as [Greetings], \n",
" @@servername as [Server Name],\n",
" datename(weekday,getutcdate()) as [Today]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Concepts\n",
"\n",
"Notebooks are saved in a file format of .ipynb and have a couple of logical components.\n",
"\n",
"**Kernel**\n",
"\n",
"The language and execution environment of the notebook. Common examples are Python and PowerShell. Azure Data Studio also offers a SQL kernel, which is the focus of this tutorial.\n",
"\n",
"**Attach To**\n",
"\n",
"This is the compute environment for the code - basically, where it will run. For SQL this is exactly analogous to the familiar Connection property of a query.\n",
"\n",
"**Cell**\n",
"\n",
"A cell is an editable section of the notebook. Cells can be human-readable text or code. Text cells are edited in the Markdown language to allow formatting and can include rich content including images. In Azure Data Studio, code cells include intellisense where possible. Below is an example of a SQL code cell.\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"(5 rows affected)"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"Total execution time: 00:00:00.163"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.dataresource+json": {
"data": [
{
"0": "59",
"1": "ASYNC_NETWORK_IO",
"2": "24",
"3": "389",
"4": "347",
"5": "0"
},
{
"0": "57",
"1": "PREEMPTIVE_XE_GETTARGETSTATE",
"2": "9",
"3": "160",
"4": "102",
"5": "0"
},
{
"0": "57",
"1": "ASYNC_NETWORK_IO",
"2": "323",
"3": "38",
"4": "2",
"5": "10"
},
{
"0": "58",
"1": "MEMORY_ALLOCATION_EXT",
"2": "5066",
"3": "25",
"4": "0",
"5": "0"
},
{
"0": "60",
"1": "PAGEIOLATCH_SH",
"2": "30",
"3": "11",
"4": "0",
"5": "0"
}
],
"schema": {
"fields": [
{
"name": "session_id"
},
{
"name": "wait_type"
},
{
"name": "waiting_tasks_count"
},
{
"name": "wait_time_ms"
},
{
"name": "max_wait_time_ms"
},
{
"name": "signal_wait_time_ms"
}
]
}
},
"text/html": [
"
| session_id | wait_type | waiting_tasks_count | wait_time_ms | max_wait_time_ms | signal_wait_time_ms |
|---|---|---|---|---|---|
| 59 | ASYNC_NETWORK_IO | 24 | 389 | 347 | 0 |
| 57 | PREEMPTIVE_XE_GETTARGETSTATE | 9 | 160 | 102 | 0 |
| 57 | ASYNC_NETWORK_IO | 323 | 38 | 2 | 10 |
| 58 | MEMORY_ALLOCATION_EXT | 5066 | 25 | 0 | 0 |
| 60 | PAGEIOLATCH_SH | 30 | 11 | 0 | 0 |