BCP数据表备份 | 您所在的位置:网站首页 › bcp数据库 › BCP数据表备份 |
(注意点:以下文字中涉及的bcp的命令不可以换行) BCP命令:BCP是SQL Server中负责导入导出数据的一个命令行工具,能以并行的方式高效地导入导出大批量的数据。BCP可以将数据库的表或视图直接导出,也能通过SELECT FROM语句对表或视图进行过滤后导出。 BCP数据表备份: --备份数据表 EXEC master..xp_cmdshell 'bcp ylzc_gyl_20180903.dbo.Adm_Authority out D:\新建文本文档.dat -T -c' --带条件的数据表备份 EXEC master..xp_cmdshell 'bcp "SELECT * FROM ylzc_gyl_20180903.dbo.Adm_Authority WHERE AuthID=''ea222ef5-cffd-45b4-a990-e85cfe351988''" queryout D:\新建文本文档4.dat -T -c' --混合模式身份验证 EXEC master..xp_cmdshell 'bcp ylzc_gyl_20180903.dbo.Adm_Authority out D:\新建文本文档.txt -c -Usa -P123456 -S.' --本地文件写入数据表中(Adm_Authority_BCP_IN先创建好表结构,再导入数据) EXEC master..xp_cmdshell 'bcp ylzc_gyl_20180903.dbo.Adm_Authority_BCP_IN in D:\新建文本文档.dat -T -c' --加上权限 sp_configure 'show advanced options',1 reconfigure go sp_configure 'xp_cmdshell',1 reconfigure go --去掉权限 sp_configure 'show advanced options',1 reconfigure go sp_configure 'xp_cmdshell',0 reconfigure go 操作过程中遇到的问题如下: 错误:EXEC master..xp_cmdshell 'bcp ylzc_gyl_20180903.dbo.Adm_Authority out D:\新建文本文档.txt -T -c' 解决方案:加上权限 sys.sp_configure 'show advanced options',1 reconfigure go sp_configure 'xp_cmdshell',1 reconfigure go 去掉权限: sp_configure 'show advanced options',1 reconfigure go sp_configure 'xp_cmdshell',0 reconfigure Go 错误2: 解决方案:sql server management studio 右键管理员运行。 |
CopyRight 2018-2019 实验室设备网 版权所有 |