介绍 (Introduction)
The Bulk copy program aka bcp is the console application used to export and import data from text files to SQL Server or vice versa.
大容量复制程序(又称为bcp)是控制台应用程序,用于将数据从文本文件导出和导入到SQL Server,反之亦然。
It is very popular because it is fast and easy to download.
它非常流行,因为它快速且易于下载。
This tool is installed by default with SQL Server. It is usually installed in the following path:
默认情况下,此工具与SQL Server一起安装。 通常将其安装在以下路径中:
Drive: \\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\bcp.exe
驱动器:\\ Program Files \ Microsoft SQL Server \ Client SDK \ ODBC \ 130 \ Tools \ Binn \ bcp.exe
In this article we will learn how to:
在本文中,我们将学习如何:
- Get the bcp arguments 获取bcp参数
- Get the version 获取版本
- Export data from a SQL Server table to a file 将数据从SQL Server表导出到文件
- Export data from a SQL Server query to a file 将数据从SQL Server查询导出到文件
- Run bcp using PowerShell 使用PowerShell运行bcp
- Run bcp on SSIS 在SSIS上运行bcp
- Invoke a batch file in SSIS 在SSIS中调用批处理文件
要求 (Requirements)
- SQL Server installed 已安装SQL Server
- bcp installed bcp
- The Adventureworks database installed 已安装Adventureworks数据库
- SSIS Installed 已安装SSIS
- SSDT installed 已安装SSDT
开始吧 (Get started)
1. Get the bcp arguments
1.获取bcp参数
In the command line, write bcp. This will show you the possible arguments that can be used:
在命令行中,编写bcp。 这将向您显示可以使用的可能参数:
bcp /? Is the same than bcp. It shows you the possible parameters:
bcp /? 与bcp相同。 它显示了可能的参数:
2. Get the version
2.获取版本
You can get the version of the bcp using the -v argument:
您可以使用-v参数获取bcp的版本: