DECLARE @TableNames AS TABLE ( id INT IDENTITY(1, 1), tableName VARCHAR(100) ); DECLARE @sTableDiff NVARCHAR(1000); DECLARE @tableName VARCHAR(100); DECLARE @counter INT; DECLARE @maxCount INT; INSERT INTO @TableNames SELECT a.name FROM sys.sysobjects a INNER JOIN ( SELECT object_id FROM sys.columns WHERE is_rowguidcol = 1 OR is_identity = 1 UNION SELECT object_id FROM sys.indexes WHERE index_id = 1 ) b ON a.id = b.object_id WHERE a.type = ‘U‘ --and a.name=‘TMonStoreCheck‘; SET @counter = 1; SELECT @maxCount = COUNT(name) FROM sys.sysobjects a INNER JOIN ( SELECT object_id FROM sys.columns WHERE is_rowguidcol = 1 OR is_identity = 1 UNION SELECT object_id FROM sys.indexes WHERE index_id = 1 ) b ON a.id = b.object_id WHERE a.type = ‘U‘ --and a.name=‘TMonStoreCheck‘; WHILE @counter <= @maxCount BEGIN SELECT @tableName = tableName FROM @TableNames WHERE id = @counter; SELECT @sTableDiff = ‘‘; SET @sTableDiff = ‘ "C:\Program Files\Microsoft SQL Server\130\COM\tablediff.exe" -sourceserver [faqb6n86e4.database.chinacloudapi.cn] -sourceuser ymjj -sourcepassword ***** -sourcedatabase xw_dl_1009676_01 -sourcetable ‘ + @tableName + ‘ -destinationserver [butt-joint] -destinationuser sa -destinationpassword ****** -destinationdatabase xw_dl_1009676_01 -destinationtable ‘+@tableName+‘ -f F:\4_9\test\‘+@tableName EXEC master..XP_CMDSHELL @sTableDiff SET @counter = @counter + 1; END;
declare @temp nvarchar(200) select @temp =‘"F:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\sqlcmd.exe" -a 32576 -S butt-joint -d xw_dl_1009676_01 -i F:\4_9\test\‘+ ? +‘ -f 65001‘ EXEC master..xp_cmdshell @temp
Shared Memory Provider: No process is on the other end of the pipe. Communication link failure ---or Msg 701, Level 17, State 139, Server *******, Line -5057 资源池“default”没有足够的系统内存来运行此查询。
exec master..xp_cmdshell ‘"F:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\bcp.exe" test.dbo.TCirOrder in F:\TCirOrder.sql -E -n -C RAW -b 1000 -a 4096 -q -S butt-joint -T‘
NULL Starting copy... SQLState = 22001, NativeError = 0 Error = [Microsoft][ODBC Driver 13 for SQL Server]String data, right truncation SQLState = 22001, NativeError = 0 Error = [Microsoft][ODBC Driver 13 for SQL Server]String data, right truncation SQLState = 22001, NativeError = 0 Error = [Microsoft][ODBC Driver 13 for SQL Server]String data, right truncation SQLState = 22001, NativeError = 0 Error = [Microsoft][ODBC Driver 13 for SQL Server]String data, right truncation SQLState = 22001, NativeError = 0 Error = [Microsoft][ODBC Driver 13 for SQL Server]String data, right truncation SQLState = 22001, NativeError = 0 Error = [Microsoft][ODBC Driver 13 for SQL Server]String data, right truncation SQLState = 22001, NativeError = 0 Error = [Microsoft][ODBC Driver 13 for SQL Server]String data, right truncation SQLState = 22001, NativeError = 0 Error = [Microsoft][ODBC Driver 13 for SQL Server]String data, right truncation SQLState = 22001, NativeError = 0 Error = [Microsoft][ODBC Driver 13 for SQL Server]String data, right truncation SQLState = 22001, NativeError = 0 Error = [Microsoft][ODBC Driver 13 for SQL Server]String data, right truncation NULL BCP copy in failed NULL
原文:https://www.cnblogs.com/jil-wen/p/10407112.html