如何使用BCP备份SQL Server中的特定表

时间:2019-05-29 10:21:05

标签: sql-server tsql

我想从指定多表中获取备份。我使用此打击代码(使用bcp):

DECLARE @table varchar(128),
        @file varchar(255),
        @cmd varchar(512)

SET @table = 'sas.Accounts' --  Table Name
SET @file = 'C:\Db_BackUps\ErpAccounting_' + @table + '_'+ CONVERT(char(8), GETDATE(), 112) + '.csv'
SET @cmd = 'bcp ' + @table + ' out ' + @file + ' -T -w '

EXEC master..Xp_cmdshell @cmd

但是我无法获取表中所有存在的数据,并且BCP不能复制所有行。我该如何解决这个问题?

0 个答案:

没有答案
相关问题