Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit 01bf234

Browse files
markingmynamerwestMSFT
authored andcommitted
[Visual Studio extensions] All new Visual Studio extensions section
1 parent af5dfb0 commit 01bf234

94 files changed

Lines changed: 735 additions & 772 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.openpublishing.publish.config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@
196196
".openpublishing.redirection.azure-data-studio.json",
197197
".openpublishing.redirection.powershell.json",
198198
".openpublishing.redirection.ssms.json",
199-
".openpublishing.redirection.stretch-database.json"
199+
".openpublishing.redirection.stretch-database.json",
200+
".openpublishing.redirection.visual-studio-code-extensions.json"
200201
]
201202
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"redirections": [
3+
{
4+
"source_path": "docs/tools/visual-studio-code/mssql-extensions.md",
5+
"redirect_url": "/sql/tools/visual-studio-code-extensions/mssql/mssql-extension-visual-studio-code",
6+
"redirect_document_id": false
7+
},
8+
{
9+
"source_path": "docs/tools/visual-studio-code/sql-server-develop-use-vscode.md",
10+
"redirect_url": "/sql/tools/visual-studio-code-extensions/mssql/connect-database-visual-studio-code",
11+
"redirect_document_id": false
12+
},
13+
{
14+
"source_path": "docs/tools/visual-studio-code/mssql-query-history.md",
15+
"redirect_url": "/sql/tools/visual-studio-code-extensions/mssql/mssql-extension-visual-studio-code",
16+
"redirect_document_id": false
17+
},
18+
{
19+
"source_path": "docs/tools/visual-studio-code/create-azure-function-with-mssql-command-palette.md",
20+
"redirect_url": "/sql/tools/visual-studio-code-extensions/sql-bindings/create-azure-function-command-palette",
21+
"redirect_document_id": false
22+
},
23+
{
24+
"source_path": "docs/tools/visual-studio-code/create-azure-function-with-mssql-object-explorer.md",
25+
"redirect_url": "/sql/tools/visual-studio-code-extensions/sql-bindings/create-azure-function-object-explorer",
26+
"redirect_document_id": false
27+
},
28+
{
29+
"source_path": "docs/tools/visual-studio-code/create-azure-function-with-mssql.md",
30+
"redirect_url": "/sql/tools/visual-studio-code-extensions/sql-bindings/create-azure-function",
31+
"redirect_document_id": false
32+
}
33+
]
34+
}

docs/toc.yml

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,8 +1320,6 @@ items:
13201320
href: relational-databases/indexes/columnstore-indexes-design-guidance.md
13211321
- name: Data loading Guidance
13221322
href: relational-databases/indexes/columnstore-indexes-data-loading-guidance.md
1323-
- name: Ordered clustered columnstore index performance
1324-
href: relational-databases/indexes/ordered-columnstore-indexes.md
13251323
- name: Query performance
13261324
href: relational-databases/indexes/columnstore-indexes-query-performance.md
13271325
- name: Real-time operational analytics
@@ -10010,24 +10008,22 @@ items:
1001010008
items:
1001110009
- name: Extended features and tools
1001210010
href: tools/download-sql-feature-packs.md
10013-
- name: Visual Studio Code
10011+
- name: Visual Studio Code extensions
1001410012
items:
10015-
- name: Overview
10016-
href: tools/visual-studio-code/mssql-extensions.md
10017-
- name: Connect and Query Tutorial
10018-
href: tools/visual-studio-code/sql-server-develop-use-vscode.md
10019-
- name: Query History
10020-
href: tools/visual-studio-code/mssql-query-history.md
10021-
- name: SQL Database Projects
10022-
href: /azure-data-studio/extensions/sql-database-project-extension
10023-
- name: SQL Bindings for Azure Functions
10013+
- name: MSSQL extension
10014+
items:
10015+
- name: Overview
10016+
href: tools/visual-studio-code-extensions/mssql/mssql-extension-visual-studio-code.md
10017+
- name: Connect and Query
10018+
href: tools/visual-studio-code-extensions/mssql/connect-database-visual-studio-code.md
10019+
- name: SQL bindings for Azure Functions
1002410020
items:
1002510021
- name: Overview
10026-
href: tools/visual-studio-code/create-azure-function-with-mssql.md
10027-
- name: From Object Explorer Tutorial
10028-
href: tools/visual-studio-code/create-azure-function-with-mssql-object-explorer.md
10029-
- name: From Command Palette Tutorial
10030-
href: tools/visual-studio-code/create-azure-function-with-mssql-command-palette.md
10022+
href: tools/visual-studio-code-extensions/sql-bindings/create-azure-function.md
10023+
- name: Object Explorer
10024+
href: tools/visual-studio-code-extensions/sql-bindings/create-azure-function-object-explorer.md
10025+
- name: Command Palette
10026+
href: tools/visual-studio-code-extensions/sql-bindings/create-azure-function-command-palette.md
1003110027
- name: Tutorials
1003210028
items:
1003310029
- name: SQL Server
@@ -10220,7 +10216,7 @@ items:
1022010216
- name: Connectivity libraries
1022110217
href: linux/sql-server-linux-develop-connectivity-libraries.md
1022210218
- name: Use Visual Studio Code
10223-
href: ./tools/visual-studio-code/sql-server-develop-use-vscode.md
10219+
href: tools/visual-studio-code-extensions/mssql/connect-database-visual-studio-code.md
1022410220
- name: Use SSDT
1022510221
href: linux/sql-server-linux-develop-use-ssdt.md
1022610222
- name: Manage
@@ -10480,8 +10476,6 @@ items:
1048010476
href: sql-server/azure-arc/security-overview.md
1048110477
- name: Configure least privilege
1048210478
href: sql-server/azure-arc/configure-least-privilege.md
10483-
- name: Set up Entra authentication
10484-
href: sql-server/azure-arc/entra-authentication-setup-tutorial.md
1048510479
- name: Configure advanced data Security
1048610480
href: sql-server/azure-arc/configure-advanced-data-security.md
1048710481
- name: Certificate rotation
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
---
2+
title: "Quickstart: Connect To and Query a Database With the MSSQL Extension for Visual Studio Code"
3+
description: Learn how to connect to a database using the MSSQL extension for Visual Studio Code, and execute Transact-SQL (T-SQL) statements to interact with your database.
4+
author: croblesm
5+
ms.author: roblescarlos
6+
ms.reviewer: maghan, randolphwest
7+
ms.date: 11/20/2024
8+
ms.service: sql
9+
ms.subservice: tools-other
10+
ms.topic: quickstart
11+
---
12+
13+
# Quickstart: Connect to and query a database with the MSSQL extension for Visual Studio Code
14+
15+
In this quickstart, you learn how to use the MSSQL extension for Visual Studio Code to connect to a database, whether it's running locally, in a container, or in the cloud. Then you learn how to use Transact-SQL (T-SQL) statements to create a database, define a table, insert data, and query results.
16+
17+
## Prerequisites
18+
19+
To complete this quickstart, you must have:
20+
21+
- **Visual Studio Code:** If you don't have Visual Studio Code installed, download and install it from the [Official Visual Studio Code website](https://code.visualstudio.com/).
22+
23+
- **MSSQL extension for Visual Studio Code:** In Visual Studio Code, open the Extensions view by selecting the Extensions icon in the Activity Bar on the side of the window. Search for `mssql` and select **Install** to add the extension.
24+
25+
- **Access to a database:** If you don't have access to a database instance, you can use one by selecting one of the following options:
26+
27+
- **Containerized SQL Server:** Run SQL Server in a Docker container for easy setup and portability. For more information, see [Quickstart: Run SQL Server Linux container images with Docker](../../../linux/quickstart-install-connect-docker.md).
28+
29+
- **Azure SQL Database:** If you prefer a cloud-based option, create a free Azure account and set up an Azure SQL Database. For more information, see [Quickstart: Create a single database - Azure SQL Database](/azure/azure-sql/database/single-database-create-quickstart).
30+
31+
- **SQL database in Fabric (preview):** If you need a simple, autonomous and secure, and optimized for AI database, create a SQL database in Fabric (preview). For more information, see [Create a SQL database in Microsoft Fabric](/fabric/database/sql/tutorial-create-database).
32+
33+
- **Local SQL Server:** Alternatively, download and install SQL Server 2022 Developer Edition on your local machine. For more information, see [Microsoft SQL Server website](https://www.microsoft.com/sql-server/sql-server-downloads).
34+
35+
- **Azure SQL Managed Instance:** If you need a fully managed SQL Server instance, create an Azure SQL Managed Instance. For more information, see [Quickstart: Create Azure SQL Managed Instance](/azure/azure-sql/managed-instance/instance-create-quickstart).
36+
37+
> [!NOTE]
38+
> If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/).
39+
40+
## Connect to a database instance
41+
42+
1. **Start Visual Studio Code:** Open the MSSQL extension for Visual Studio Code** by selecting the server viewlet on the left side of the window or by pressing `Ctrl+Alt+D`.
43+
44+
The first time you run the MSSQL extension for Visual Studio Code, the **Enable Experiences and Reload** button appears when the extension is loaded for the first time.
45+
46+
1. **Connect to database:**
47+
48+
This article uses the **Parameter** input type and **SQL Login** for the authentication type.
49+
50+
Follow the prompts to specify the properties for the new connection profile. Complete each field as follows:
51+
52+
| Connection property | Value | Description |
53+
| --- | --- | --- |
54+
| **Profile Name** (optional) | Leave this field blank. | Type a name for the connection profile. such as *localhost profile*. |
55+
| **Server name** | Enter the server name here. Ex: localhost | Specify the SQL Server instance name. Use *localhost* to connect to a SQL Server instance on your local machine. To connect to a remote SQL Server, enter the name of the target SQL Server, or its IP address. To connect to a SQL Server container, specify the IP address of the container's host machine. If you need to specify a port, use a comma to separate it from the name. For example, for a server listening on port 1401, enter `<servername or IP>,1401`.<br /><br />By default, the connection string uses port 1433. A default instance of SQL Server uses 1433 unless modified. If your instance is listening on 1433, you don't need to specify the port.<br />As an alternative, you can enter the ADO connection string for your database here. |
56+
| **Trust Server Certificate** | Check this field. | Select this option to trust the server certificate. |
57+
| **Input type** | Parameter. | Choose from **Parameter**, **Connection String**, or **Browse Azure**. |
58+
| **Database name** (optional) | \<Default>. | The database that you want to use. To connect to the default database, don't specify a database name here. |
59+
| **Authentication Type** | SQL login. | Choose either **SQL Login**, **Windows Authentication**, or **Microsoft Entra ID**. |
60+
| **User name** | Enter your *\<username\>* for the SQL Server. | If you selected **SQL Login**, enter the name of a user with access to a database on the server. |
61+
| **Password** | Enter your *\<password\>* for the SQL Server. | Enter the password for the specified user. |
62+
| **Save Password** | Check this field to save the password for future connections. | Press **Enter** to select **Yes** and save the password. Select **No** to be prompted for the password each time the connection profile is used. |
63+
| **Encrypt** | **Mandatory**. | Choose from **Yes**, **No**, or **Mandatory**. |
64+
65+
After you enter all values and select **Enter**, Visual Studio Code creates the connection profile and connects to the SQL Server.
66+
67+
:::image type="content" source="media/connect-database-visual-studio-code/mssql-connection-dialog-parameters.png" alt-text="Screenshot of the Connection Dialog window." lightbox="media/connect-database-visual-studio-code/mssql-connection-dialog-parameters.png":::
68+
69+
## Create a database
70+
71+
Let's start by creating a database called `Library`.
72+
73+
1. Open a new query editor: Press `Ctrl+N` to open a new query editor, or right-click on your server and select **New Query**.
74+
75+
1. Create the database by pasting the following snippet into the query editor and selecting **Run**:
76+
77+
```sql
78+
IF NOT EXISTS (SELECT name
79+
FROM sys.databases
80+
WHERE name = N'Library')
81+
CREATE DATABASE Library;
82+
```
83+
84+
This script creates a new database called `Library` if it doesn't already exist.
85+
86+
The new `Library` database appears in the list of databases. If you don't see it immediately, refresh the Object Explorer.
87+
88+
## Create a table
89+
90+
Now, let's create the `Authors` table within the `Library` database.
91+
92+
1. Open a new query editor and make sure the connection context is set to the `Library` database.
93+
94+
1. The following code creates the `Authors` table with an `IDENTITY` column for the primary key. Replace the text in the query window with the following snippet and select **Run**:
95+
96+
```sql
97+
CREATE TABLE dbo.Authors
98+
(
99+
id INT IDENTITY (1, 1) NOT NULL PRIMARY KEY,
100+
first_name NVARCHAR (100) NOT NULL,
101+
middle_name NVARCHAR (100) NULL,
102+
last_name NVARCHAR (100) NOT NULL
103+
);
104+
```
105+
106+
This script creates the `Authors` table with an `IDENTITY` column for the `id`, which automatically generates unique IDs.
107+
108+
## Insert rows
109+
110+
Now, let's insert some data into the `Authors` table.
111+
112+
1. Replace the text in the query window with the following snippet and select **Run**:
113+
114+
```sql
115+
INSERT INTO dbo.Authors (first_name, middle_name, last_name)
116+
VALUES ('Isaac', 'Yudovick', 'Asimov'),
117+
('Arthur', 'Charles', 'Clarke'),
118+
('Herbert', 'George', 'Wells'),
119+
('Jules', 'Gabriel', 'Verne'),
120+
('Philip', 'Kindred', 'Dick');
121+
```
122+
123+
As a result, the sample data is added to the `Authors` table.
124+
125+
## View the data
126+
127+
To verify the data in the `Authors` table, run the following query:
128+
129+
```sql
130+
SELECT *
131+
FROM dbo.Authors;
132+
```
133+
134+
This query returns all records in the `Authors` table, showing the data you inserted.
135+
136+
## Related content
137+
138+
- [What is the MSSQL extension for Visual Studio Code?](mssql-extension-visual-studio-code.md)
139+
- [Tutorial: Write Transact-SQL statements](../../../t-sql/tutorial-writing-transact-sql-statements.md)
140+
- [Learn more about contributing to the mssql extension](https://github.com/Microsoft/vscode-mssql/wiki)
141+
- [What is the local development experience for Azure SQL Database?](/azure/azure-sql/database/local-dev-experience-overview)
42.4 KB
Loading
42.4 KB
Loading
9.13 KB
Loading
9.28 KB
Loading
8.36 KB
Loading
44.6 KB
Loading

0 commit comments

Comments
 (0)