The following steps show how to create a notebook file in Azure Data Studio:
In Azure Data Studio, connect to your SQL Server.
Select under the Connections in the Servers window. Then select New Notebook.
Wait for the Kernel and the target context (Attach to) to be populated. Confirm that the Kernel is set to SQL, and set Attach to for your SQL Server (in this example it's localhost).
You can save the notebook using the Save or Save as... command from the File menu.
To open a notebook, you can use the Open file... command in the File menu, select Open file on the Welcome page, or use the File: Open command from the command palette.
Change the SQL connection
To change the SQL connection for a notebook:
Select the Attach to menu from the notebook toolbar and then select Change Connection.
Now you can either select a recent connection server or enter new connection details to connect.
Run a code cell
You can create cells containing SQL code that you can run in place by clicking the Run cell button (the round black arrow) to the left of the cell. The results are shown in the notebook after the cell finishes running.
For example:
Add a new code cell by selecting the +Code command in the toolbar.
Copy and paste the following example into the cell and click Run cell. This example creates a new database.
SQL
USEmasterGO-- Drop the database if it already existsIFEXISTS (
SELECTnameFROM sys.databases
WHEREname = N'TestNotebookDB'
)
DROPDATABASE TestNotebookDB
GO-- Create the databaseCREATEDATABASE TestNotebookDB
GO
Save the result
If you run a script that returns a result, you can save that result in different formats using the toolbar displayed above the result.
Save As CSV
Save As Excel
Save As JSON
Save As XML
For example, the following code returns the result of PI.
You can use Polyglot Notebooks to create and run code in multiple languages in a single document. This module introduces you to Polyglot Notebooks and shows you how to create and run code in multiple languages.
Administer an SQL Server database infrastructure for cloud, on-premises and hybrid relational databases using the Microsoft PaaS relational database offerings.