跨服务器查询sql语句样例(转)
若2个数据库在同一台机器上:
insert into DataBase_A..Table1(col1,col2,col3----)
select col11,col22,col33-- from DataBase_B..Table11
若不在同一台机器上,则是本文要讲的内容:
-----------------------------------------------------------------------------------------
跨服务器查询sql语句样例
INSERT INTO [目标数据库名].[dbo].[表名]
([Target_ID]
,[Target_Name])
select * from
OPENDATASOURCE('SQLOLEDB','Data Source=服务器;DBN=源数据库名;UID=用户名;PWD=密码').源数据库名.dbo.[表名]
但上述查询需要开启外围数据库查询
先选中 master 数据库,新建一个查询,执行以下的sql
开户外围:
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
-------------------------------
关闭外围:
exec sp_configure 'show advanced options',0
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
跨服务器查询sql语句样例(转)的更多相关文章
- 跨服务器查询sql语句样例
若2个数据库在同一台机器上:insert into DataBase_A..Table1(col1,col2,col3----)select col11,col22,col33-- from Data ...
- sqlserver跨服务器数据库sql语句
1.启用Ad Hoc Distributed Queries:exec sp_configure 'show advanced options',1reconfigureexec sp_configu ...
- 跨服务器查询sql (摘要)
首先推荐一个神作:http://www.cnblogs.com/daniel206/archive/2008/01/16/1041748.html 大神比较详细了.而且条理很清晰. 然后摘录一些其他的 ...
- 跨服务器的SQL语句如何书写
select * into 本地库名..表名 from OPENDATASOURCE( 'SQLOLEDB', 'Data ...
- sql 跨服务器查询数据
方法一:用OPENDATASOURCE [SQL SERVER] 跨服务器查询 --1 打开 reconfigure reconfigure SELECT * FROM OPENDATASOURCE( ...
- 跨服务器查询信息的sql
--跨服务器查询信息的sql: select * from openrowset( 'SQLOLEDB', '192.168.1.104'; 'sa'; '123.com',[AutoMonitorD ...
- SQL Server跨服务器查询的实现方法,OpenDataSource
SQL Server跨服务器查询的方法我们经常需要用到,下面就为您介绍两种SQL Server跨服务器查询的方法,如果您感兴趣的话,不妨一看. SQL Server跨服务器查询方法一:用OPENDAT ...
- sqlserver 两 表 数据 复制 (附加 跨服务器 查询的方法)
一 : 这个sql 语句 可以快速的 将 一 个旧表 中的指定字段的数据 复制到 另一个新表的指定字段中 insert into dbo.Customer ( CustomerId , Custome ...
- SQLServer 跨服务器查询的两个办法
网上搜了跨服务器查询的办法,大概就是Linked Server(预存连接方式并保证连接能力)和OpenDataSource(写在语句中,可移植性强).根据使用函数的不同,性能差别显而易见...虽然很简 ...
随机推荐
- C++多线程下出现内存越界问题总结
工作中遇到这样一个问题,某个多级流水多线程的程序,在压力测试下会偶现segmentation fault11错误,错误出现在运行类函数的地方,而后排查后发现是由于多线程争抢导致类被析构后才走入判断,导 ...
- 企业架构 Red Hat Drools KIE Project 三大核心产品
美团放弃Drools自研规则引擎: https://blog.csdn.net/qq_18603599/article/details/80767912 Drools rule engine虽然好,但 ...
- java 库 pdfbox 将 pdf 文件转换成高清图片方法
近期需要将 pdf 文件转成高清图片,使用库是 pdfbox.fontbox.可以使用 renderImageWithDPI 方法指定转换的清晰度,当然清晰度越高,转换需要的时间越长,转换出来的图片越 ...
- linux中环境变量和系统加载环境变量的顺序
一.系统环境变量: /etc/profile :这个文件预设了几个重要的变量,例如PATH, USER, LOGNAME, MAIL, INPUTRC, HOSTNAME, HISTSIZE, uma ...
- [LeetCode] 60. Permutation Sequence 序列排序
The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the p ...
- [LeetCode] 126. Word Ladder II 词语阶梯 II
Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformat ...
- [LeetCode] 218. The Skyline Problem 天际线问题
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...
- 【Sqoop学习之一】Sqoop简介
环境 sqoop-1.4.6 Sqoop:将关系数据库(oracle.mysql.postgresql等)数据与hadoop数据进行转换的工具. 两个版本:两个版本完全不兼容,sqoop1使用最多:s ...
- vscode插件Power Mode
Power Mode官网 设置里添加 "powermode.enabled": true, "powermode.presets": "flames& ...
- 2019 西安邀请赛 M
Problem Description There are n planets ∼n. Each planet is connected to other planets through some t ...