sqlserver跨库查询

将ScciDB数据库中的表数据,插入到同样表结构的另外一个数据库当中
exec sp_configure "show advanced options",1
reconfigure
exec sp_configure "Ad Hoc Distributed Queries",1
reconfigure
insert into tb_cityCode SELECT *
from OPENROWSET('MSDASQL',
   'DRIVER={SQL Server};SERVER=192.168.1.6\sqlexpress;UID=sa;PWD=123456',
   ScciDB.dbo.[tb_cityCode]) 
   
insert into tb_warehouse SELECT *
from OPENROWSET('MSDASQL',
   'DRIVER={SQL Server};SERVER=192.168.1.6\sqlexpress;UID=sa;PWD=123456',
   ScciDB.dbo.[tb_warehouse])    

exec sp_configure "Ad Hoc Distributed Queries",0
reconfigure
exec sp_configure "show advanced options",0
reconfigure 

猜你喜欢

转载自libixionglbx.iteye.com/blog/1477385