惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Privacy & Cybersecurity Law Blog
V
V2EX
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Register - Security
The Register - Security
MongoDB | Blog
MongoDB | Blog
P
Privacy International News Feed
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
美团技术团队
Stack Overflow Blog
Stack Overflow Blog
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
V
Visual Studio Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
K
Kaspersky official blog
S
Secure Thoughts
T
Tenable Blog
Security Latest
Security Latest
The Cloudflare Blog
S
Security @ Cisco Blogs
H
Heimdal Security Blog
aimingoo的专栏
aimingoo的专栏
TaoSecurity Blog
TaoSecurity Blog
Blog — PlanetScale
Blog — PlanetScale
Microsoft Security Blog
Microsoft Security Blog
Schneier on Security
Schneier on Security
Webroot Blog
Webroot Blog
G
Google Developers Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Scott Helme
Scott Helme
IT之家
IT之家
Latest news
Latest news
The Hacker News
The Hacker News
C
Check Point Blog
T
The Exploit Database - CXSecurity.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More
腾讯CDC
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
N
News | PayPal Newsroom
Forbes - Security
Forbes - Security
P
Palo Alto Networks Blog
S
Security Affairs
S
Securelist
Google Online Security Blog
Google Online Security Blog
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
A
About on SuperTechFans

博客园 - Machine Lee

js动态更换img的src问题 JQuery应用集合 SVN自动更新测试服务器工作副本(C#写winform程序实现) 学习《SQL Server 2005管理员大全》时遇到的困难 ASP.NET根据URL生成网页缩略图示例程序(C#语言) 传参防SQL注入函数 web.config中sessionState节点的配置方案 SQL中DateTime转换成Varchar样式 ASP错误信息提示函数 - Machine Lee - 博客园 ASP操作Excel技术总结[转载收藏] js控制文本框只能输入整数或浮点数 正则表达式验证可发短信的号码,如手机号和小灵通号码(106+区号+号码) SQL中实现Split的功能函数 GridView中CheckBox客户端全选 验证多行文本框输入长度的正则表达式 TreeView动态构造多级树并实现拖动(收藏) javascript写的日历控件(收藏) javascript获取TreeView控件选中节点的Text和Value TreeView绑定XML数据源C#代码示例
两台服务器上SQL Server数据库数据互操作示例
Machine Lee · 2012-10-17 · via 博客园 - Machine Lee

数据库之间的数据操作*/
--创建链接服务器
exec sp_addlinkedserver   'ITSV ', ' ', 'SQLOLEDB ', '远程服务器名或ip地址 '
exec sp_addlinkedsrvlogin 'ITSV ', 'false ',null, '用户名 ', '密码 ' --查询示例
select * from ITSV.数据库名.dbo.表名 --导入示例
select * intofrom ITSV.数据库名.dbo.表名 --以后不再使用时删除链接服务器
exec sp_dropserver  'ITSV ', 'droplogins ' --连接远程/局域网数据(openrowset/openquery/opendatasource)
--
1、openrowset

--查询示例
select * from openrowset( 'SQLOLEDB ', 'sql服务器名 '; '用户名 '; '密码 ',数据库名.dbo.表名) --生成本地表
select * intofrom openrowset( 'SQLOLEDB ', 'sql服务器名 '; '用户名 '; '密码 ',数据库名.dbo.表名) --把本地表导入远程表
insert openrowset( 'SQLOLEDB ', 'sql服务器名 '; '用户名 '; '密码 ',数据库名.dbo.表名)
select *from 本地表 --更新本地表
update b
set b.列A=a.列A
from openrowset( 'SQLOLEDB ', 'sql服务器名 '; '用户名 '; '密码 ',数据库名.dbo.表名)as a inner join 本地表 b
on a.column1=b.column1 --openquery用法需要创建一个连接

--首先创建一个连接创建链接服务器
exec sp_addlinkedserver   'ITSV ', ' ', 'SQLOLEDB ', '远程服务器名或ip地址 '
--查询
select *
FROM openquery(ITSV,  'SELECT *  FROM 数据库.dbo.表名 ')
--把本地表导入远程表
insert openquery(ITSV,  'SELECT *  FROM 数据库.dbo.表名 ')
select * from 本地表
--更新本地表
update b
set b.列B=a.列B
FROM openquery(ITSV,  'SELECT * FROM 数据库.dbo.表名 ') as
inner join 本地表 b on a.列A=b.列A --3、opendatasource/openrowset
SELECT   *
FROM   opendatasource( 'SQLOLEDB ''Data Source=ip/ServerName;User ID=登陆名;Password=密码 ' ).test.dbo.roy_ta

posted on 2012-10-17 16:02  Machine Lee  阅读(2906)  评论()    收藏  举报