今早上同事要求从SQLServer2008导出一部分数据到SQLServer2000中作为演示/测试数据,开始也没想多,直接去SQLServer2000的企业管理器中,用了数据导入的功能。以为完事了,后来有要求导入更多表,SQLServer2000中勾选表,太痛苦。干脆直接用语句写。
truncate Table TableTest
go
insert into TableTest
select * from openrowset('SQLOLEDB','Server=192.168.0.229;PWD=sa;UID=sa;','select * from TEST.dbo.TableTest') as t
原以为很简单,在SQLServer2008中测试,一运行,报错:
问了百度,这么解决:
首先运行下边的语句:
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
然后执行 openrowset
操作完了之后,再关掉上边的开关:
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure