You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Do a quickstart in which you use Azure Data Studio to connect to SQL Server and then use Transact-SQL (T-SQL) statements to create a database.
4
4
author: erinstellato-ms
5
5
ms.author: erinstellato
6
-
ms.reviewer: "maghan"
7
-
ms.date: 07/11/2022
6
+
ms.reviewer: maghan, randolphwest
7
+
ms.date: 01/16/2023
8
8
ms.service: azure-data-studio
9
9
ms.topic: "quickstart"
10
10
ms.custom:
@@ -18,25 +18,25 @@ This quickstart shows how to use Azure Data Studio to connect to SQL Server, and
18
18
19
19
## Prerequisites
20
20
21
-
To complete this quickstart, you need Azure Data Studio, and access to SQL Server.
21
+
To complete this quickstart, you need Azure Data Studio, and access to a SQL Server instance.
22
22
23
23
-[Install Azure Data Studio](./download-azure-data-studio.md).
24
24
25
25
If you don't have access to a SQL Server, select your platform from the following links (make sure you remember your SQL Login and Password!):
26
26
27
-
-[Windows - Download SQL Server 2019 Developer Edition](https://www.microsoft.com/sql-server/sql-server-downloads)
28
-
-[macOS - Download SQL Server 2019 on Docker](../linux/quickstart-install-connect-docker.md)
29
-
-[Linux - Download SQL Server 2019 Developer Edition](../linux/sql-server-linux-overview.md#install) - You only need to follow the steps up to *Create and Query Data*.
27
+
-[Windows - Download SQL Server 2022 Developer Edition](https://www.microsoft.com/sql-server/sql-server-downloads)
28
+
-[Linux - Download SQL Server 2022 in a container](../linux/quickstart-install-connect-docker.md)
29
+
-[Linux - Download SQL Server 2022 Developer Edition](../linux/sql-server-linux-overview.md#install) - You only need to follow the steps up to *Create and Query Data*.
30
30
31
31
## Connect to a SQL Server
32
32
33
33
1. Start **Azure Data Studio**.
34
34
35
-
2. The first time you run Azure Data Studio the **Welcome** page should open. If you don't see the **Welcome** page, select **Help** > **Welcome**. Select **New Connection** to open the **Connection** pane:
35
+
1. The first time you run Azure Data Studio the **Welcome** page should open. If you don't see the **Welcome** page, select **Help** > **Welcome**. Select **New Connection** to open the **Connection** pane:
:::image type="content" source="media/quickstart-sql-server/new-connection-screen.png" alt-text="Screenshot showing the New Connection screen.":::
49
49
50
50
## Create a database
51
51
52
52
The following steps create a database named **TutorialDB**:
53
53
54
54
1. Right-click on your server, **localhost**, and select **New Query**.
55
55
56
-
2. Paste the following snippet into the query window: and then select **Run**.
57
-
58
-
```sql
59
-
USE master
60
-
GO
61
-
IF NOT EXISTS (
62
-
SELECT name
63
-
FROMsys.databases
64
-
WHERE name = N'TutorialDB'
65
-
)
66
-
CREATE DATABASE [TutorialDB];
67
-
GO
68
-
IF SERVERPROPERTY('ProductVersion') >'12'
69
-
ALTERDATABASE [TutorialDB] SET QUERY_STORE=ON;
70
-
GO
71
-
```
56
+
1. Paste the following snippet into the query window: and then select **Run**.
57
+
58
+
```sql
59
+
USE master;
60
+
GO
61
+
62
+
IF NOT EXISTS (
63
+
SELECT name
64
+
FROMsys.databases
65
+
WHERE name = N'TutorialDB'
66
+
)
67
+
CREATE DATABASE [TutorialDB];
68
+
GO
69
+
70
+
IF SERVERPROPERTY('ProductVersion') >'12'
71
+
ALTERDATABASE [TutorialDB] SET QUERY_STORE =ON;
72
+
GO
73
+
```
72
74
73
75
After the query completes, the new **TutorialDB** appears in the list of databases. If you don't see it, right-click the **Databases** node and select **Refresh**.
2. Paste the following snippet into the query window and click **Run**:
86
-
87
-
> [!NOTE]
88
-
> You can append this too, or overwrite the previous query in the editor. Note that clicking **Run** executes only the query that is selected. If nothing is selected, clicking **Run** executes all queries in the editor.
89
-
90
-
```sql
91
-
-- Create a new table called 'Customers' in schema 'dbo'
92
-
-- Drop the table if it already exists
93
-
IF OBJECT_ID('dbo.Customers', 'U') IS NOT NULL
94
-
DROP TABLE dbo.Customers;
95
-
GO
96
-
-- Create the table in the specified schema
97
-
CREATE TABLE dbo.Customers
98
-
(
99
-
CustomerId int NOT NULL PRIMARY KEY, -- primary key column
100
-
Name nvarchar(50) NOT NULL,
101
-
Location nvarchar(50) NOT NULL,
102
-
Email nvarchar(50) NOT NULL
103
-
);
104
-
GO
85
+
:::image type="content" source="media/quickstart-sql-server/change-context.png" alt-text="Screenshot showing how to change context.":::
86
+
87
+
1. Paste the following snippet into the query window and select**Run**:
88
+
89
+
> [!NOTE]
90
+
> You can append this too, or overwrite the previous query in the editor. Note that selecting**Run** executes only the query that is selected. If nothing is selected, selecting**Run** executes all queries in the editor.
91
+
92
+
```sql
93
+
-- Create a new table called 'Customers' in schema 'dbo'
After the query completes, the new **Customers** table appears in the list of tables. You might need to right-click the **TutorialDB > Tables** node andselect**Refresh**.
108
110
109
111
## Insert rows
110
112
111
-
- Paste the following snippet into the query window and click **Run**:
0 commit comments