Skip to content

Commit 77a9901

Browse files
Merge pull request #37121 from MicrosoftDocs/main
Auto Publish – main to live - 2026-04-22 22:30 UTC
2 parents 90d0fc2 + 2f2a828 commit 77a9901

10 files changed

Lines changed: 1549 additions & 1269 deletions

.openpublishing.redirection.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53937,17 +53937,17 @@
5393753937
},
5393853938
{
5393953939
"source_path": "docs/connect/odbc/connecting-with-bcp.md",
53940-
"redirect_url": "/sql/tools/bcp-utility",
53940+
"redirect_url": "/sql/tools/bcp/bcp-utility",
5394153941
"redirect_document_id": false
5394253942
},
5394353943
{
5394453944
"source_path": "docs/connect/odbc/linux/connecting-with-bcp.md",
53945-
"redirect_url": "/sql/tools/bcp-utility",
53945+
"redirect_url": "/sql/tools/bcp/bcp-utility",
5394653946
"redirect_document_id": false
5394753947
},
5394853948
{
5394953949
"source_path": "docs/connect/odbc/linux-mac/connecting-with-bcp.md",
53950-
"redirect_url": "/sql/tools/bcp-utility",
53950+
"redirect_url": "/sql/tools/bcp/bcp-utility",
5395153951
"redirect_document_id": false
5395253952
},
5395353953
{
@@ -67630,6 +67630,11 @@
6763067630
"redirect_url": "/sql/tools/sqlcmd/sqlcmd-utility",
6763167631
"redirect_document_id": true
6763267632
},
67633+
{
67634+
"source_path": "docs/tools/bcp-utility.md",
67635+
"redirect_url": "/sql/tools/bcp/bcp-utility",
67636+
"redirect_document_id": true
67637+
},
6763367638
{
6763467639
"source_path": "docs/ssms/scripting/edit-sqlcmd-scripts-with-query-editor.md",
6763567640
"redirect_url": "/sql/tools/sqlcmd/edit-sqlcmd-scripts-query-editor",

docs/relational-databases/sql-server-transaction-locking-and-row-versioning-guide.md

Lines changed: 191 additions & 91 deletions
Large diffs are not rendered by default.

docs/t-sql/statements/alter-availability-group-transact-sql.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ Specifies manual seeding. This method requires you to create a backup of the dat
676676
Modifies any of the availability group settings of a distributed availability group. The list of availability groups to modify contains the availability group name and a `WITH (...)` clause for each availability group.
677677

678678
> [!IMPORTANT]
679-
> You must run this command on both the primary availability group and secondary availability group instances.
679+
> You must run this command on both the primary availability group and secondary availability group instances as `sysadmin`.
680680
681681
#### GRANT CREATE ANY DATABASE
682682

docs/toc.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4835,7 +4835,7 @@ items:
48354835
- name: SQL Server Integration Services (SSIS) >
48364836
href: ./integration-services/sql-server-integration-services.md
48374837
- name: Bulk Copy Utility (bcp)
4838-
href: tools/bcp-utility.md
4838+
href: tools/bcp/bcp-utility.md
48394839
- name: Big data options on the Microsoft SQL Server platform
48404840
href: big-data-cluster/big-data-options.md
48414841
- name: Azure Migration Services >
@@ -8455,9 +8455,19 @@ items:
84558455
href: tools/configuration-manager/viewing-the-sql-server-error-log.md
84568456
- name: Viewing the Windows Application Log
84578457
href: tools/configuration-manager/viewing-the-windows-application-log.md
8458+
- name: BCP (bulk copy utility)
8459+
items:
8460+
- name: Overview
8461+
href: tools/bcp/bcp-utility.md
8462+
- name: Download and install
8463+
href: tools/bcp/bcp-download-install.md
8464+
- name: Authenticate bcp with Microsoft Entra ID
8465+
href: tools/bcp/bcp-authentication.md
8466+
- name: Use the utility
8467+
href: tools/bcp/bcp-use-utility.md
84588468
- name: SQLCMD
84598469
items:
8460-
- name: sqlcmd overview
8470+
- name: Overview
84618471
href: tools/sqlcmd/sqlcmd-utility.md
84628472
- name: Check installed version
84638473
href: tools/sqlcmd/sqlcmd-installed-version.md

docs/tools/bcp-utility.md

Lines changed: 0 additions & 1118 deletions
This file was deleted.
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
---
2+
title: Authenticate with Microsoft Entra ID in bcp
3+
description: Use Microsoft Entra ID to authenticate the bulk copy program (bcp) utility against Azure SQL, Microsoft Fabric SQL database, or SQL Server 2022 and later versions.
4+
author: rwestMSFT
5+
ms.author: randolphwest
6+
ms.reviewer: davidengel
7+
ms.date: 04/19/2026
8+
ms.service: sql
9+
ms.subservice: tools-other
10+
ms.topic: how-to
11+
ms.collection:
12+
- data-tools
13+
ms.custom:
14+
- linux-related-content
15+
- peer-review-program
16+
helpviewer_keywords:
17+
- "bcp utility [SQL Server], authentication"
18+
- "bcp utility [SQL Server], Microsoft Entra ID"
19+
- "Microsoft Entra ID, bcp"
20+
- "managed identity, bcp"
21+
monikerRange: ">=azuresqldb-current || =azure-sqldw-latest || >=sql-server-2016 || >=sql-server-linux-2017 || =fabric-sqldb"
22+
---
23+
# Authenticate with Microsoft Entra ID in bcp
24+
25+
[!INCLUDE [SQL Server Azure SQL Database Synapse Analytics FabricSQLDB](../../includes/applies-to-version/sql-asdb-asdbmi-asa-fabricsqldb.md)]
26+
27+
The [bulk copy program utility (bcp)](bcp-utility.md) supports several Microsoft Entra ID authentication models when you connect to Azure SQL Database, Azure SQL Managed Instance, [!INCLUDE [fabric-sqldb](../../includes/fabric-sqldb.md)], Azure Synapse Analytics, or [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)] and later versions.
28+
29+
To check whether your installed **bcp** supports Microsoft Entra authentication, run `bcp --help` and verify that `-G` appears in the list of available arguments.
30+
31+
## Platform restrictions
32+
33+
Not all authentication modes are available on every platform:
34+
35+
- Microsoft Entra interactive authentication is supported on Windows only.
36+
37+
- Microsoft Entra integrated authentication on Linux and macOS requires [Microsoft ODBC Driver 18 for SQL Server](../../connect/odbc/download-odbc-driver-for-sql-server.md) (driver 17.6.1 or later if you can't move to driver 18) and a [properly configured Kerberos environment](../../connect/odbc/linux-mac/using-integrated-authentication.md#configure-kerberos).
38+
39+
- Authentication with an access token file (`-P <token_file>`) is supported on Linux and macOS only.
40+
41+
## Microsoft Entra username and password
42+
43+
Provide `-G` together with `-U` (username) and `-P` (password).
44+
45+
The following example exports table `bcptest` from database `testdb` on `contoso.database.windows.net` to file `c:\last\data1.dat`. Replace `<password>` with a valid password.
46+
47+
```console
48+
bcp bcptest out "c:\last\data1.dat" -c -S contoso.database.windows.net -d testdb -G -U alice@contoso.onmicrosoft.com -P <password>
49+
```
50+
51+
The following example imports the same data:
52+
53+
```console
54+
bcp bcptest in "c:\last\data1.dat" -c -S contoso.database.windows.net -d testdb -G -U alice@contoso.onmicrosoft.com -P <password>
55+
```
56+
57+
## Microsoft Entra integrated
58+
59+
Provide `-G` without `-U` or `-P`. The current Windows account (or Kerberos identity on Linux/macOS) must be federated with Microsoft Entra ID. In the following examples, replace `<server>` with your server name.
60+
61+
Export:
62+
63+
```console
64+
bcp bcptest out "c:\last\data2.dat" -S <server>.database.windows.net -d testdb -G -c
65+
```
66+
67+
Import:
68+
69+
```console
70+
bcp bcptest in "c:\last\data2.dat" -S <server>.database.windows.net -d testdb -G -c
71+
```
72+
73+
## Microsoft Entra Managed Service Identity
74+
75+
Authenticate as either a system-assigned or user-assigned managed identity through a configured DSN. The same approach works for both `bcp in` and `bcp out`.
76+
77+
> [!IMPORTANT]
78+
> **bcp** is tightly coupled to its driver. The major version of **bcp** must match the major version of the driver the DSN is created with. To determine your **bcp** version, run `bcp -v`.
79+
80+
### [Windows](#tab/windows)
81+
82+
Configure a DSN through the **ODBC Data Source Administrator**:
83+
84+
1. Press the Windows key on your keyboard.
85+
1. Type `ODBC` and select the appropriate version of the **ODBC Data Source Administrator**.
86+
1. Select either the **User DSN** or **System DSN** tab.
87+
1. Select **Add** and follow the prompts.
88+
1. When asked for an authentication type, select **Azure Managed Service Identity authentication**.
89+
1. For a User Assigned Managed Identity, paste the `Object (principal) ID` of the identity into the **Login ID** box on the authentication tab.
90+
1. Continue following the prompts to finish configuring the DSN.
91+
92+
For a full walkthrough including screenshots, see [Creating and editing DSNs in the UI](../../connect/odbc/using-azure-active-directory.md#creating-and-editing-dsns-in-the-ui).
93+
94+
Use the `-D` flag to indicate that the value passed to `-S` is a DSN. The `-D` and `-S` switches can appear in any order on the command line.
95+
96+
```console
97+
bcp bcptest out "c:\last\data1.dat" -c -D -S myDSN -d testdb
98+
```
99+
100+
### [Linux and macOS](#tab/linux)
101+
102+
Edit the user `.odbc.ini` file (typically at `~/.odbc.ini`). Run `odbcinst -j` to confirm the DSN file location.
103+
104+
```bash
105+
vi /home/<user>/.odbc.ini
106+
```
107+
108+
Add an entry like the following. Omit the `LastUser` line for a system-assigned managed identity. Replace `<server>` and `<object_id_of_user_assigned_managed_identity>` with values for your environment.
109+
110+
```ini
111+
[myDSN]
112+
Driver = ODBC Driver 18 for SQL Server
113+
Server = <server>.database.windows.net
114+
Database = testdb
115+
Encrypt = yes
116+
LastUser = <object_id_of_user_assigned_managed_identity>
117+
Authentication = ActiveDirectoryMSI
118+
```
119+
120+
Use the `-D` flag to indicate that the value passed to `-S` is a DSN. The `-D` and `-S` switches can appear in any order on the command line.
121+
122+
```bash
123+
bcp bcptest out data1.dat -c -D -S myDSN -d testdb
124+
```
125+
126+
---
127+
128+
## Microsoft Entra ID access token
129+
130+
**Applies to**: Linux and macOS only. Windows isn't supported.
131+
132+
**bcp** 17.8 and later versions on Linux and macOS can authenticate with an access token. The following examples use the [Azure CLI](/cli/azure/install-azure-cli-linux) to retrieve the token and write it to a secure temporary file.
133+
134+
> [!IMPORTANT]
135+
> The token file must be UTF-16LE without a BOM. Restrict file permissions and delete the file when it's no longer needed, as shown in the following examples.
136+
137+
### System-assigned managed identity
138+
139+
Replace `<server>` with your server name.
140+
141+
1. Sign in with your managed identity:
142+
143+
```bash
144+
az login --identity
145+
```
146+
147+
1. Retrieve the token, write it to a secure temporary file, and run **bcp**:
148+
149+
```bash
150+
# Create a secure temporary file for the token
151+
tokenFile=$(mktemp)
152+
chmod 600 "$tokenFile"
153+
154+
# Retrieve the access token and write it as UTF-16LE without BOM
155+
az account get-access-token --resource https://database.windows.net --output tsv | cut -f 1 | tr -d '\n' | iconv -f ascii -t UTF-16LE > "$tokenFile"
156+
157+
# Run bcp with the token file
158+
bcp bcptest out data2.dat -S <server>.database.windows.net -d testdb -G -P "$tokenFile" -c
159+
160+
# Clean up token file
161+
rm -f "$tokenFile"
162+
```
163+
164+
### User-assigned managed identity
165+
166+
1. Sign in with your user-assigned managed identity. Replace `<client_id>` with a valid value for your environment.
167+
168+
```bash
169+
az login --identity --username <client_id>
170+
```
171+
172+
1. Retrieve the token, write it to a secure temporary file, and run **bcp**. Replace `<server>` with a valid value for your environment.
173+
174+
```bash
175+
# Create a secure temporary file for the token
176+
tokenFile=$(mktemp)
177+
chmod 600 "$tokenFile"
178+
179+
# Retrieve the access token and write it as UTF-16LE without BOM
180+
az account get-access-token --resource https://database.windows.net --output tsv | cut -f 1 | tr -d '\n' | iconv -f ascii -t UTF-16LE > "$tokenFile"
181+
182+
# Run bcp with the token file
183+
bcp bcptest out data2.dat -S <server>.database.windows.net -d testdb -G -P "$tokenFile" -c
184+
185+
# Clean up token file
186+
rm -f "$tokenFile"
187+
```
188+
189+
## Microsoft Entra interactive
190+
191+
**Applies to**: Windows only. Linux and macOS aren't supported.
192+
193+
Microsoft Entra interactive authentication uses a dialog to authenticate, and supports multifactor authentication (MFA). Interactive authentication requires **bcp** [version 15.0.1000.34](bcp-download-install.md#download-the-latest-version) or later, and [ODBC Driver 18 for SQL Server](../../connect/odbc/download-odbc-driver-for-sql-server.md) (or driver 17.2 or later).
194+
195+
Provide `-G` with `-U` (username) only. Don't include `-P`. **bcp** prompts for the password (or for accounts with MFA enabled, completes the configured MFA flow).
196+
197+
```console
198+
bcp bcptest out "c:\last\data1.dat" -c -S contoso.database.windows.net -d testdb -G -U alice@contoso.onmicrosoft.com
199+
```
200+
201+
For a Microsoft Entra user that's a Windows account from a federated domain, include the domain in the username (for example, `joe@contoso.com`):
202+
203+
```console
204+
bcp bcptest out "c:\last\data1.dat" -c -S contoso.database.windows.net -d testdb -G -U joe@contoso.com
205+
```
206+
207+
If guest users in a Microsoft Entra tenant are part of a group that has database permissions in [!INCLUDE [ssazure-sqldb](../../includes/ssazure-sqldb.md)], use the guest user alias (for example, `keith0@adventure-works.com`).
208+
209+
## Related content
210+
211+
- [bcp utility](bcp-utility.md)
212+
- [Download and install the bcp utility](bcp-download-install.md)
213+
- [How to use the bcp utility](bcp-use-utility.md)
214+
- [Microsoft Entra authentication for Azure SQL](/azure/azure-sql/database/authentication-aad-overview)
215+
- [Authentication in SQL database in Microsoft Fabric](/fabric/database/sql/authentication)
216+
217+
[!INCLUDE [get-help-options](../../includes/paragraph-content/get-help-options.md)]
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
title: Download and Install the bcp Utility
3+
description: Learn how to download and install the bulk copy program (bcp) utility on Windows, Linux, and macOS.
4+
author: rwestMSFT
5+
ms.author: randolphwest
6+
ms.reviewer: davidengel
7+
ms.date: 04/19/2026
8+
ms.service: sql
9+
ms.subservice: tools-other
10+
ms.topic: how-to
11+
ms.collection:
12+
- data-tools
13+
ms.custom:
14+
- linux-related-content
15+
- peer-review-program
16+
helpviewer_keywords:
17+
- "bcp utility [SQL Server], download"
18+
- "bcp utility [SQL Server], install"
19+
- "command prompt utilities [SQL Server], bcp"
20+
- "Microsoft Command Line Utilities for SQL Server"
21+
monikerRange: ">=aps-pdw-2016 || =azuresqldb-current || =azure-sqldw-latest || >=sql-server-2016 || >=sql-server-linux-2017 || =fabric-sqldb"
22+
---
23+
# Download and install the bcp utility
24+
25+
[!INCLUDE [SQL Server Azure SQL Database Synapse Analytics PDW FabricSQLDB](../../includes/applies-to-version/sql-asdb-asdbmi-asa-pdw-fabricsqldb.md)]
26+
27+
The [bulk copy program utility (bcp)](bcp-utility.md) bulk copies data between an instance of [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] and a data file in a user-specified format.
28+
29+
For detailed information about using **bcp** with Azure Synapse Analytics, see [Load data with bcp](/azure/sql-data-warehouse/sql-data-warehouse-load-with-bcp).
30+
31+
## Identify installed version
32+
33+
To determine the installed version of **bcp**, run the following command:
34+
35+
```console
36+
bcp -v
37+
```
38+
39+
If multiple versions of **bcp** are installed on Windows, the `PATH` environment variable determines which one runs. To list every copy of `bcp.exe` on the search path, use the following command:
40+
41+
```console
42+
where bcp.exe
43+
```
44+
45+
For information about how to set the command path in the `PATH` environment variable, see [Environment variables](/windows/win32/shell/user-environment-variables).
46+
47+
## bcp versioning
48+
49+
The **bcp** utility is versioned independently of the [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] release it ships with:
50+
51+
| **bcp** major version | Distribution |
52+
| --- | --- |
53+
| 18 | Ships with [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)]. Adds `-Y` (TLS encryption mode) and `-u` (trust server certificate) switches. |
54+
| 15 | Distributed as Microsoft Command Line Utilities 15 for SQL Server, and bundled with [!INCLUDE [sssql19-md](../../includes/sssql19-md.md)] and [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)] tools. |
55+
56+
## Download the latest version
57+
58+
The following instructions are for **bcp** running on Windows. For instructions on installing **bcp** on Linux and macOS, as well as system requirements, see [Install the sqlcmd and bcp SQL Server command-line tools on Linux](../../linux/sql-server-linux-setup-tools.md).
59+
60+
| Package | Platform |
61+
| --- | --- |
62+
| Microsoft Command Line Utilities 15 for SQL Server | [x64](https://go.microsoft.com/fwlink/?linkid=2230791)&emsp;[x86](https://go.microsoft.com/fwlink/?linkid=2231320) |
63+
64+
The Microsoft Command Line Utilities package contains both **bcp** and **sqlcmd** (ODBC). It also installs (or requires) the [Microsoft ODBC Driver for SQL Server](../../connect/odbc/download-odbc-driver-for-sql-server.md).
65+
66+
> [!NOTE]
67+
> The standalone **bcp** download might not have the same release and build number as the **bcp** that ships with the latest [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] cumulative update (CU). This behavior is expected. The standalone download still contains all fixes included in the latest CU.
68+
69+
## System requirements
70+
71+
The following system requirements are for **bcp** running on Windows.
72+
73+
- Windows 10 and later versions
74+
- Windows Server 2016 and later versions
75+
- [Microsoft ODBC Driver for SQL Server](../../connect/odbc/download-odbc-driver-for-sql-server.md) (driver 18 is recommended)
76+
77+
## Related content
78+
79+
- [bcp utility](bcp-utility.md)
80+
- [How to use the bcp utility](bcp-use-utility.md)
81+
- [Authenticate with Microsoft Entra ID in bcp](bcp-authentication.md)
82+
- [Prepare data for bulk export or import](../../relational-databases/import-export/prepare-data-for-bulk-export-or-import-sql-server.md)
83+
- [BULK INSERT (Transact-SQL)](../../t-sql/statements/bulk-insert-transact-sql.md)
84+
- [OPENROWSET (Transact-SQL)](../../t-sql/functions/openrowset-transact-sql.md)
85+
- [Format files to import or export data (SQL Server)](../../relational-databases/import-export/format-files-for-importing-or-exporting-data-sql-server.md)
86+
87+
[!INCLUDE [get-help-options](../../includes/paragraph-content/get-help-options.md)]

0 commit comments

Comments
 (0)