我正在尝试将数据从一个数据库复制到另一个数据库(在不同的服务器上),其表具有相同的架构,每次运行以下查询时,我都会收到一条错误消息...
“SQLState = 22008 NativeError = 0 错误 = [Microsoft][SQL Server Native Client 10.0] 日期格式无效”
查询是这样的...
EXEC sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
EXEC sp_configure 'xp_cmdshell', 1
GO
RECONFIGURE
GO
DECLARE @MasterServerName varchar(40)
DECLARE @MasterServerUserName varchar(20)
DECLARE @MasterServerPassword varchar(20)
DECLARE @SlaveServerName varchar(40)
DECLARE @SlaveServerUserName varchar(20)
DECLARE @SlaveServerPassword varchar(20)
DECLARE @ExportFile varchar (40)
DECLARE @ExportFile1 varchar (40)
DECLARE @ExportFile2 varchar (40)
DECLARE @ExportFile3 varchar (40)
DECLARE @ExportFile4 varchar (40)
SET @MasterServerName='{SQL_Server_Name}'
SET @MasterServerUserName='{SQL_USER_LOGIN}'
SET @MasterServerPassword='{SQL_USER_PASSWORD}'
SET @SlaveServerName='{SLAVE_NAME}\{SLAVE_INSTANCE}'
SET @SlaveServerUserName='{SLAVE_USER_LOGIN}'
SET @SlaveServerPassword='{SLAVE_USER_PASSWORD}'
-------------------------------------
SET @ExportFile1='C:\ExportTracking1.txt'
SET @ExportFile2='C:\ExportTracking2.txt'
SET @ExportFile3='C:\ExportTracking3.txt'
SET @ExportFile4='C:\ExportTracking4.txt'
DECLARE @BCP varchar(8000)
----------------------------------------------
--Collecting tracking data from the slave server
-----------------------------------------------
SET @BCP =
'bcp "select * FROM <DATABASE_NAME>.dbo.<TABLE_NAME> where ExportID="9999999"" queryoutout '+@ExportFile1+' -c -U'+@SlaveServerUserName+' -P'+@SlaveServerPassword+' -S'+@SlaveServerName+' -C{850}'
PRINT @BCP
EXEC xp_CMDshell @BCP
-----------------------------------------------
--Adding tracking data to the master server
-----------------------------------------------
SET @BCP =
'bcp <DATABASE_NAME>.dbo.<TABLE_NAME> in '+@ExportFile1+' -e C:\error1.txt -c -U'+@MasterServerUserName+' -P'+@MasterServerPassword+' -S'+@MasterServerName+' -C{850}'
PRINT @BCP
EXEC xp_CMDshell @BCP
-----------------------------------------------
EXEC sp_configure 'xp_cmdshell', 0
GO
RECONFIGURE
GO
EXEC sp_configure 'show advanced options', 0
GO
RECONFIGURE
GO
任何人都可以帮助阐明为什么会发生此错误吗?
任何投入将不胜感激。
谢谢
李