SQL Server 不同数据库导入指定数据解决方案
生活随笔
收集整理的這篇文章主要介紹了
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
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
總結
以上是生活随笔為你收集整理的SQL Server 不同数据库导入指定数据解决方案的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: js对浏览器内部及外部窗口宽度及高度使用
- 下一篇: linux cmake编译源码,linu