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
{{ message }}
Repository navigation
Commit a1b4e4f
Browse filesBrowse the repository at this point in the historyBrowse files
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.
[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.
- A database in Azure SQL Database or Azure SQL Managed Instance. You can use one of these quickstarts to create and then configure a database in Azure SQL Database:
| Configure |[Server-level IP firewall rule](firewall-create-server-level-portal-quickstart.md))|[Connectivity from a virtual machine (VM)](../managed-instance/connect-vm-instance-configure.md)|
| Configure |[Server-level IP firewall rule](firewall-create-server-level-portal-quickstart.md))|[Connectivity from a virtual machine (VM)](../managed-instance/connect-vm-instance-configure.md)|
33
34
|||[Connectivity from on-premises](../managed-instance/point-to-site-p2s-configure.md)
34
35
|Load data|Wide World Importers loaded per quickstart|[Restore Wide World Importers](../managed-instance/restore-sample-database-quickstart.md)
35
-
|||Restore or import Adventure Works from a [BACPAC](database-import.md) file from [GitHub](https://github.com/Microsoft/sql-server-samples/tree/master/samples/databases/adventure-works)|
36
+
|||Restore or import Adventure Works from a [BACPAC](database-import.md) file from [GitHub](https://github.com/Microsoft/sql-server-samples/tree/master/samples/databases/adventure-works)|
36
37
37
-
> [!IMPORTANT]
38
+
> [!IMPORTANT]
38
39
> The scripts in this article are written to use the Adventure Works database. With a SQL Managed Instance, you must either import the Adventure Works database into an instance database or modify the scripts in this article to use the Wide World Importers database.
39
40
40
41
## Install Visual Studio Code
@@ -44,7 +45,7 @@ Make sure you have installed the latest [Visual Studio Code](https://code.visual
44
45
45
46
## Configure Visual Studio Code
46
47
47
-
### **macOS**
48
+
### macOS
48
49
49
50
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**.
@@ -71,45 +72,45 @@ Get the connection information you need to connect to Azure SQL Database. You'll
71
72
72
73
1. Sign in to the [Azure portal](https://portal.azure.com/).
73
74
74
-
2. Navigate to the **SQL databases** or **SQL Managed Instances** page.
75
+
1. Navigate to the **SQL databases** or **SQL Managed Instances** page.
75
76
76
-
3. On the **Overview** page, review the fully qualified server name next to **Server name** for SQL Database or the fully qualified server name next to **Host** for a SQL Managed Instance. To copy the server name or host name, hover over it and select the **Copy** icon.
77
+
1. On the **Overview** page, review the fully qualified server name next to **Server name** for SQL Database or the fully qualified server name next to **Host** for a SQL Managed Instance. To copy the server name or host name, hover over it and select the **Copy** icon.
77
78
78
79
## Set language mode to SQL
79
80
80
81
In Visual Studio Code, set the language mode to **SQL** to enable mssql commands and T-SQL IntelliSense.
81
82
82
83
1. Open a new Visual Studio Code window.
83
84
84
-
2. Press **Ctrl**+**N**. A new plain text file opens.
85
+
1. Press **Ctrl**+**N**. A new plain text file opens.
85
86
86
-
3. Select **Plain Text** in the status bar's lower right-hand corner.
87
+
1. Select **Plain Text** in the status bar's lower right-hand corner.
87
88
88
-
4. In the **Select language mode**drop-down menu that opens, select **SQL**.
89
+
1. In the **Select language mode**dropdown list that opens, select **SQL**.
89
90
90
91
## Connect to your database
91
92
92
93
Use Visual Studio Code to establish a connection to your server.
93
94
94
-
> [!IMPORTANT]
95
-
> Before continuing, make sure that you have your server and signin 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.
95
+
> [!IMPORTANT]
96
+
> 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.
96
97
97
98
1. In Visual Studio Code, press **Ctrl+Shift+P** (or **F1**) to open the Command Palette.
98
99
99
-
2. Select **MS SQL:Connect** and choose **Enter**.
100
+
1. Select **MS SQL:Connect** and choose **Enter**.
100
101
101
-
3. Select **Create Connection Profile**.
102
+
1. Select **Create Connection Profile**.
102
103
103
-
4. Follow the prompts to specify the new profile's connection properties. After specifying each value, choose **Enter** to continue.
104
+
1. Follow the prompts to specify the new profile's connection properties. After specifying each value, choose **Enter** to continue.
2. Press **Ctrl**+**Shift**+**E** to run the query and display results from the `Product` and `ProductCategory` tables.
132
+
1. Press **Ctrl**+**Shift**+**E** to run the query and display results from the `Product` and `ProductCategory` tables.
131
133
132
-

134
+
:::image type="content" source="./media/connect-query-vscode/query.png" alt-text="Screenshot of query to retrieve data from 2 tables.":::
133
135
134
136
## Insert data
135
137
@@ -138,25 +140,27 @@ Run the following [INSERT](/sql/t-sql/statements/insert-transact-sql) Transact-S
138
140
1. Replace the previous query with this one.
139
141
140
142
```sql
141
-
INSERT INTO [SalesLT].[Product]
142
-
([Name]
143
-
,[ProductNumber]
144
-
,[Color]
145
-
,[ProductCategoryID]
146
-
,[StandardCost]
147
-
,[ListPrice]
148
-
,[SellStartDate])
149
-
VALUES
150
-
('myNewProduct'
151
-
,123456789
152
-
,'NewColor'
153
-
,1
154
-
,100
155
-
,100
156
-
,GETDATE());
143
+
INSERT INTO [SalesLT].[Product] (
144
+
[Name],
145
+
[ProductNumber],
146
+
[Color],
147
+
[ProductCategoryID],
148
+
[StandardCost],
149
+
[ListPrice],
150
+
[SellStartDate]
151
+
)
152
+
VALUES (
153
+
'myNewProduct',
154
+
123456789,
155
+
'NewColor',
156
+
1,
157
+
100,
158
+
100,
159
+
GETDATE()
160
+
);
157
161
```
158
162
159
-
2. Press **Ctrl**+**Shift**+**E** to insert a new row in the `Product` table.
163
+
1. Press **Ctrl**+**Shift**+**E** to insert a new row in the `Product` table.
160
164
161
165
## Update data
162
166
@@ -170,7 +174,7 @@ Run the following [UPDATE](/sql/t-sql/queries/update-transact-sql) Transact-SQL
170
174
WHERE Name ='myNewProduct';
171
175
```
172
176
173
-
2. Press **Ctrl**+**Shift**+**E** to update the specified row in the `Product` table.
177
+
1. Press **Ctrl**+**Shift**+**E** to update the specified row in the `Product` table.
174
178
175
179
## Delete data
176
180
@@ -183,10 +187,10 @@ Run the following [DELETE](/sql/t-sql/statements/delete-transact-sql) Transact-S
183
187
WHERE Name ='myNewProduct';
184
188
```
185
189
186
-
2. Press **Ctrl**+**Shift**+**E** to delete the specified row in the `Product` table.
190
+
1. Press **Ctrl**+**Shift**+**E** to delete the specified row in the `Product` table.
187
191
188
192
## Next steps
189
193
190
-
-To connect and query using SQL Server Management Studio, see [Quickstart: Use SQL Server Management Studio to connect to a database in Azure SQL Database and query data](connect-query-ssms.md).
191
-
-To connect and query using the Azure portal, see [Use the SQL Query editor in the Azure portal to connect and query data](query-editor.md).
192
-
-For an MSDN magazine article on using Visual Studio Code, see [Create a database IDE with MSSQL extension blog post](/archive/msdn-magazine/2017/june/data-points-visual-studio-code-create-a-database-ide-with-mssql-extension).
194
+
-[Quickstart: Use SQL Server Management Studio to connect to a database in Azure SQL Database and query data](connect-query-ssms.md)
195
+
-[Use the SQL Query editor in the Azure portal to connect and query data](query-editor.md)
196
+
-[Create a database IDE with MSSQL extension blog post](/archive/msdn-magazine/2017/june/data-points-visual-studio-code-create-a-database-ide-with-mssql-extension)
Copy file name to clipboardExpand all lines: docs/ssma/access/exporting-an-access-inventory-accesstosql.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
@@ -104,7 +104,7 @@ For more information about adding databases to projects, see [Adding and Removin
104
104
105
105
1. If your instance of [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] is configured to accept connections on a non-default port, enter the port number that is used for [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] connections in the **Server port** box. For the default instance of [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)], the default port number is 1433. For named instances, SSMA tries to obtain the port number from the [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] Browser Service.
106
106
107
-
1. In the **Authentication** dropdown list menu, select the authentication type to use for the connection. To use the current Windows account, select **Windows Authentication**. To use a [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] login, select **SQL Server Authentication**, and then provide a user name and password.
107
+
1. In the **Authentication** dropdown list, select the authentication type to use for the connection. To use the current Windows account, select **Windows Authentication**. To use a [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] login, select **SQL Server Authentication**, and then provide a user name and password.
108
108
109
109
For more information about connecting to [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)], see [Connecting to SQL Server (AccessToSQL)](../../ssma/access/connecting-to-sql-server-accesstosql.md).
0 commit comments