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: Learn how to connect to Azure SQL Database or SQL Managed Instance on Azure by using Visual Studio Code. Then, run Transact-SQL (T-SQL) statements to query and edit data.
4
+
description: Learn how to connect to Azure SQL Database or Azure SQL Managed Instance by using Visual Studio Code. Then, run Transact-SQL (T-SQL) statements to query and edit data.
[Visual Studio Code](https://code.visualstudio.com/docs) is a graphical code editor for Linux, macOS, and Windows. It supports extensions, including the [mssql extension](https://aka.ms/mssql-marketplace) for querying a SQL Server instance, Azure SQL Database, an Azure SQL Managed Instance, and a database in Azure Synapse Analytics. In this quickstart, you'll use Visual Studio Code to connect to Azure SQL Database or Azure SQL Managed Instance and then run Transact-SQL statements to query, insert, update, and delete data.
21
+
[Visual Studio Code](https://code.visualstudio.com/docs) is a graphical code editor for Linux, macOS, and Windows. It supports extensions, including the [mssql extension](https://aka.ms/mssql-marketplace) for querying SQL Server, Azure SQL Database, Azure SQL Managed Instance, and a database in Azure Synapse Analytics. In this quickstart, you use Visual Studio Code to connect to Azure SQL Database or Azure SQL Managed Instance and then run Transact-SQL statements to query, insert, update, and delete data.
Make sure you have installed the latest [Visual Studio Code](https://code.visualstudio.com/Download) and loaded the [mssql extension](https://aka.ms/mssql-marketplace). For guidance on installing the mssql extension, see [Install Visual Studio Code](/sql/linux/sql-server-linux-develop-use-vscode#install-and-start-visual-studio-code) and [mssql for Visual Studio Code
Make sure you have installed the latest [Visual Studio Code](https://code.visualstudio.com/Download). For installation guidance, see [Install Visual Studio Code](/sql/linux/sql-server-linux-develop-use-vscode#install-and-start-visual-studio-code).
45
43
46
44
## Configure Visual Studio Code
47
45
46
+
### Windows
47
+
48
+
Load the [mssql extension](https://aka.ms/mssql-marketplace) by following these steps:
49
+
50
+
1. Open Visual Studio Code.
51
+
1. Open the Extensions pane (or **Ctrl + Shift + X**).
52
+
1. Search for `sql` and then install the **SQL Server (mssql)** extension.
53
+
54
+
For additional installation guidance, see [mssql for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-mssql.mssql).
55
+
48
56
### macOS
49
57
50
58
For macOS, you need to install OpenSSL, which is a prerequisite for .NET Core that mssql extension uses. Open your terminal and enter the following commands to install **brew** and **OpenSSL**.
Load the [mssql extension](https://aka.ms/mssql-marketplace) by following these steps:
64
72
65
-
### Windows
73
+
1. Open Visual Studio Code.
74
+
1. Open the Extensions pane (or **Ctrl + Shift + X**).
75
+
1. Search for `sql` and then install the **SQL Server (mssql)** extension.
66
76
67
-
No special configuration needed.
77
+
For additional installation guidance, see [mssql for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-mssql.mssql).
68
78
69
79
## Get server connection information
70
80
71
-
Get the connection information you need to connect to Azure SQL Database. You'll need the fully qualified server name or host name, database name, and login information for the upcoming procedures.
81
+
Get the connection information you need to connect to Azure SQL Database. You need the fully qualified server name or host name, database name, and login information for the upcoming procedures.
72
82
73
83
1. Sign in to the [Azure portal](https://portal.azure.com/).
74
84
@@ -82,7 +92,7 @@ In Visual Studio Code, set the language mode to **SQL** to enable mssql command
82
92
83
93
1. Open a new Visual Studio Code window.
84
94
85
-
1. Press **Ctrl**+**N**. A new plain text file opens.
95
+
1. Press **Ctrl + N**. A new plain text file opens.
86
96
87
97
1. Select **Plain Text** in the status bar's lower right-hand corner.
88
98
@@ -95,13 +105,13 @@ Use Visual Studio Code to establish a connection to your server.
95
105
> [!IMPORTANT]
96
106
> Before continuing, make sure that you have your server and sign-in information ready. Once you begin entering the connection profile information, if you change your focus from Visual Studio Code, you have to restart creating the profile.
97
107
98
-
1. In Visual Studio Code, press **Ctrl+Shift+P** (or **F1**) to open the Command Palette.
108
+
1. In Visual Studio Code, press **Ctrl + Shift + P** (or **F1**) to open the Command Palette.
99
109
100
-
1.Select **MS SQL:Connect**and choose **Enter**.
110
+
1.Type `connect`and then choose **MS SQL:Connect**.
101
111
102
-
1. Select **Create Connection Profile**.
112
+
1. Select **+ Create Connection Profile**.
103
113
104
-
1. Follow the prompts to specify the new profile's connection properties. After specifying each value, choose**Enter** to continue.
114
+
1. Follow the prompts to specify the new profile's connection properties. After specifying each value, press**Enter** to continue.
105
115
106
116
| Property | Suggested value | Description |
107
117
| --- | --- | --- |
@@ -129,9 +139,9 @@ Run the following [SELECT](/sql/t-sql/queries/select-transact-sql) Transact-SQL
129
139
ONpc.ProductCategoryId=p.ProductCategoryId;
130
140
```
131
141
132
-
1. Press **Ctrl**+**Shift**+**E** to run the query and display results from the `Product` and `ProductCategory` tables.
142
+
1. Press **Ctrl + Shift + E** to run the query and display results from the `Product` and `ProductCategory` tables.
133
143
134
-
:::image type="content" source="./media/connect-query-vscode/query.png" alt-text="Screenshot of query to retrieve data from 2 tables.":::
144
+
:::image type="content" source="./media/connect-query-vscode/query.png" alt-text="Screenshot of query to retrieve data from 2 tables." lightbox="./media/connect-query-vscode/query.png":::
135
145
136
146
## Insert data
137
147
@@ -160,7 +170,7 @@ Run the following [INSERT](/sql/t-sql/statements/insert-transact-sql) Transact-S
160
170
);
161
171
```
162
172
163
-
1. Press **Ctrl**+**Shift**+**E** to insert a new row in the `Product` table.
173
+
1. Press **Ctrl + Shift + E** to insert a new row in the `Product` table.
164
174
165
175
## Update data
166
176
@@ -174,7 +184,7 @@ Run the following [UPDATE](/sql/t-sql/queries/update-transact-sql) Transact-SQL
174
184
WHERE Name ='myNewProduct';
175
185
```
176
186
177
-
1. Press **Ctrl**+**Shift**+**E** to update the specified row in the `Product` table.
187
+
1. Press **Ctrl + Shift + E** to update the specified row in the `Product` table.
178
188
179
189
## Delete data
180
190
@@ -187,7 +197,7 @@ Run the following [DELETE](/sql/t-sql/statements/delete-transact-sql) Transact-S
187
197
WHERE Name ='myNewProduct';
188
198
```
189
199
190
-
1. Press **Ctrl**+**Shift**+**E** to delete the specified row in the `Product` table.
200
+
1. Press **Ctrl + Shift + E** to delete the specified row in the `Product` table.
This quickstart teaches you how to connect to Azure SQL Managed Instance by using [SQL Server Management Studio](/sql/ssms/sql-server-management-studio-ssms) (SSMS) from an on-premises client computer over a point-to-site connection. For information about point-to-site connections, see [About Point-to-Site VPN](/azure/vpn-gateway/point-to-site-about).
18
19
@@ -50,59 +51,68 @@ This quickstart:
50
51
51
52
1. Paste the script in your PowerShell window and provide the required parameters. The values for `<subscriptionId>`, `<resourceGroup>`, and `<virtualNetworkName>` should match the ones that you used for the [Create a managed instance](instance-create-quickstart.md) quickstart. The value for `<certificateNamePrefix>` can be a string of your choice.
52
53
53
-
> [!NOTE]
54
-
> If you get an error about parsing the Internet Explorer engine, either launch Internet Explorer to complete the initial set up or upgrade to a newer version of PowerShell.
54
+
> [!NOTE]
55
+
> If you get an error about parsing the Internet Explorer engine, either launch Internet Explorer to complete the initial set up or upgrade to a newer version of PowerShell.
55
56
56
57
1. Execute the PowerShell script.
57
58
58
-
> [!IMPORTANT]
59
+
> [!IMPORTANT]
59
60
> Do not continue until the PowerShell script completes.
60
61
61
62
## Create a VPN connection
62
63
63
64
1. Sign in to the [Azure portal](https://portal.azure.com/).
64
-
2. Open the resource group where you created the virtual network gateway, and then open the virtual network gateway resource.
65
-
3. Select **Point-to-site configuration** and then select **Download VPN client**.
65
+
1. Open the resource group where you created the virtual network gateway, and then open the virtual network gateway resource.
66
+
1. Select **Point-to-site configuration** and then select **Download VPN client**.
66
67
67
-

68
+
:::image type="content" source="./media/point-to-site-p2s-configure/download-vpn-client.png" alt-text="Screenshot of the Gateway Point to site configuration page for the virtual network of your SQL managed instance in the Azure portal." lightbox="./media/point-to-site-p2s-configure/download-vpn-client.png":::
68
69
69
-
4. On your on-premises client computer, extract the files from the zip file and then open the folder with the extracted files.
70
-
5. Open the **WindowsAmd64** folder and open the **VpnClientSetupAmd64.exe** file.
71
-
6. If you receive a **Windows protected your PC** message, select **More info** and then select **Run anyway**.
70
+
1. On your on-premises client computer, extract the files from the zip file and then open the folder with the extracted files.
71
+
1. Open the **WindowsAmd64** folder and open the **VpnClientSetupAmd64.exe** file.
72
+
1. If you receive a **Windows protected your PC** message, select **More info** and then select **Run anyway**.
72
73
73
-

74
+
:::image type="content" source="./media/point-to-site-p2s-configure/vpn-client-defender.png" alt-text="Screenshot of Windows Defender asking if you're sure you want to install the VPN client.":::
74
75
75
-
7. In the User Account Control dialog box, select **Yes** to continue.
76
-
8. In the dialog box referencing your virtual network, select **Yes** to install the VPN client for your virtual network.
76
+
1. In the User Account Control dialog box, select **Yes** to continue.
77
+
1. In the dialog box referencing your virtual network, select **Yes** to install the VPN client for your virtual network.
77
78
78
79
## Connect to the VPN connection
79
80
80
81
1. Go to **VPN** in **Network & Internet** on your on-premises client computer and select your SQL managed instance virtual network to establish a connection to this VNet. In the following image, the VNet is named **MyNewVNet**:
81
82
82
-

83
+
:::image type="content" source="./media/point-to-site-p2s-configure/vpn-connection.png" alt-text="Screenshot of the Windows VPN connection screen.":::
83
84
84
-
2. Select **Connect**.
85
-
3. In the dialog box, select **Connect**.
85
+
1. Select **Connect**.
86
+
1. In the dialog box, select **Connect**.
86
87
87
-

88
+
:::image type="content" source="./media/point-to-site-p2s-configure/vpn-connection2.png" alt-text="Screenshot of the VPN that highlights the Connect button.":::
88
89
89
-
4. When you're prompted that Connection Manager needs elevated privileges to update your route table, choose **Continue**.
90
-
5. Select **Yes** in the User Account Control dialog box to continue.
90
+
1. When you're prompted that Connection Manager needs elevated privileges to update your route table, choose **Continue**.
91
+
1. Select **Yes** in the User Account Control dialog box to continue.
91
92
92
93
You've established a VPN connection to your SQL managed instance VNet.
93
94
94
-

95
+
:::image type="content" source="./media/point-to-site-p2s-configure/vpn-connection-succeeded.png" alt-text="Screenshot of the Windows VPN connection screen that highlights the Connected message when you've established your connection.":::
95
96
96
97
## Connect with SSMS
97
98
98
99
1. On the on-premises client computer, open SQL Server Management Studio (SSMS).
99
-
2. In the **Connect to Server** dialog box, enter the fully qualified **host name** for your SQL managed instance in the **Server name** box.
100
-
3. Select **SQL Server Authentication**, provide your username and password, and then select **Connect**.
100
+
1. In the **Connect to Server** dialog box, enter the fully qualified **host name** for your SQL managed instance in the **Server name** box.
101
+
1. Select **SQL Server Authentication**, provide your username and password, and then select **Connect**.
101
102
102
-

103
+
:::image type="content" source="./media/point-to-site-p2s-configure/ssms-connect.png" alt-text="Screenshot of the Connect to Server dialog box in SSMS.":::
103
104
104
105
After you connect, you can view your system and user databases in the Databases node. You can also view various objects in the Security, Server Objects, Replication, Management, SQL Server Agent, and XEvent Profiler nodes.
105
106
107
+
## Connection could not be established
108
+
109
+
If your connection works initially but after some time, you see the error `The connection could not be established` when you try to connect to the VPN, follow these steps:
110
+
111
+
1. Open your Windows **VPN Settings**.
112
+
1. Remove the VPN connection.
113
+
1. Repeat the steps in [Create a VPN connection](#create-a-vpn-connection) to download the VPN client and install it again.
114
+
1. Connect to the VPN.
115
+
106
116
## Next steps
107
117
108
118
- For a quickstart showing how to connect from an Azure virtual machine, see [Configure a point-to-site connection](point-to-site-p2s-configure.md).
Copy file name to clipboardExpand all lines: docs/database-engine/availability-groups/windows/administration-of-an-availability-group-sql-server.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -105,7 +105,7 @@ helpviewer_keywords:
105
105
[SQL Server Customer Advisory Team Whitepapers](https://techcommunity.microsoft.com/t5/DataCAT/bg-p/DataCAT/)
106
106
107
107
## See Also
108
-
[Always On Availability Groups (SQL Server)](../../../database-engine/availability-groups/windows/always-on-availability-groups-sql-server.md)
108
+
[Always On Availability Groups (SQL Server)](../../../database-engine/availability-groups/windows/overview-of-always-on-availability-groups-sql-server.md)
109
109
[Overview of Always On Availability Groups (SQL Server)](../../../database-engine/availability-groups/windows/overview-of-always-on-availability-groups-sql-server.md)
110
110
[Configuration of a Server Instance for Always On Availability Groups (SQL Server)](../../../database-engine/availability-groups/windows/configuration-of-a-server-instance-for-always-on-availability-groups-sql-server.md)
111
111
[Creation and Configuration of Availability Groups (SQL Server)](../../../database-engine/availability-groups/windows/creation-and-configuration-of-availability-groups-sql-server.md)
0 commit comments