我正在尝试将数据从一个数据库复制到另一个数据库(在不同服务器上),这些数据库的表具有相同的模式,每次运行以下查询时都会出现错误,说明以下内容......
“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
有人可以帮助解释为什么会出现这种错误吗?
非常感谢任何输入。
由于
利
答案 0 :(得分:0)
不太可能但也可能,请检查运行sql实例的Windows服务器的语言和区域设置。