{
"metadata": {
"kernelspec": {
"name": "SQL",
"display_name": "SQL",
"language": "sql"
},
"language_info": {
"name": "sql",
"version": ""
}
},
"nbformat_minor": 2,
"nbformat": 4,
"cells": [
{
"cell_type": "markdown",
"source": "
\r\n\r\n## SQL Notebooks in Azure Data Studio\r\n\r\nNotebooks 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. \r\n",
"metadata": {}
},
{
"cell_type": "code",
"source": "select \r\n 'Hello SQL World' as [Greetings], \r\n @@servername as [Server Name],\r\n datename(weekday,getutcdate()) as [Today]",
"metadata": {},
"outputs": [],
"execution_count": 1
},
{
"cell_type": "markdown",
"source": "### Concepts\r\n\r\nNotebooks are saved in a file format of .ipynb and have a couple of logical components.\r\n\r\n**Kernel**\r\n\r\nThe language and execution environment of the notebook. Common examples are Python, R, Scala, and Spark. Azure Data Studio also offers a SQL kernel, which is the focus of this tutorial.\r\n\r\n**Attach To**\r\n\r\nThis 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.\r\n\r\n**Cell**\r\n\r\nA 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.\r\n",
"metadata": {}
},
{
"cell_type": "code",
"source": "select top 5 * from sys.dm_exec_session_wait_stats order by wait_time_ms desc",
"metadata": {},
"outputs": [
{
"output_type": "display_data",
"data": {
"text/html": "(5 rows affected)"
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/html": "Total execution time: 00:00:00.163"
},
"metadata": {}
},
{
"output_type": "execute_result",
"metadata": {},
"execution_count": 7,
"data": {
"application/vnd.dataresource+json": {
"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"
}
]
},
"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"
}
]
},
"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 |