Fork me on GitHub

SQL Server 不同数据库导入指定数据解决方案

 1 use 待导入DB
2 go
3
4 /*启动Ad Hoc Distributed Queries*/
5 exec sp_configure 'show advanced options',1
6 reconfigure
7 exec sp_configure 'Ad Hoc Distributed Queries',1
8 reconfigure
9
10 insert into 待导入DB.dbo.表名
11 select top 10 sid from opendatasource('SQLOLEDB','data source=ip;USER ID=sa;PASSWORD=sa').数据源DB.dbo.表名
12
13
14 /*关闭Ad Hoc Distributed Queries*/
15 exec sp_configure 'Ad Hoc Distributed Queries',0
16 reconfigure
17 exec sp_configure 'show advanced options',0
18 reconfigure
posted @ 2012-03-28 12:04  磊哥|www.javacn.site  阅读(382)  评论(0编辑  收藏  举报