bcp实践
bcp命令介绍
bcp 实用工具可以在 Microsoft SQL Server 实例和用户指定格式的数据文件间大容量复制数据。 使用 bcp 实用工具可以将大量新行导入 SQL Server 表,或将表数据导出到数据文件。 除非与 queryout 选项一起使用,否则使用该实用工具不需要了解 Transact-SQL 知识。 若要将数据导入表中,必须使用为该表创建的格式文件,或者必须了解表的结构以及对于该表中的列有效的数据类型。
参数
常用的参数有-t -c -T in导入 out 导出
bcp hoho…user_info out d:\ttse\test1111.txt -c -t , -Uusername -Ppassword -Sservername
将hoho库中的user_info导出到本地的d:\ttse\文件名为test1111.txt
当然你也可以使用-f 指定导出的格式
bcp hoho…user_info in d:\ttse\test1111.txt -c -t , -Uusername -Ppassword -Sservername
#将本地的d:\ttse\文件名为test1111.txt导入到hoho库中的user_info表中
queryout的使用
bcp “select * from nono…user_info where regedate >‘2020/06/14’” queryout d:\222.txt -c -t , -Ubill -Psuntek -Snxdx168db