Home > Database > Mysql Tutorial > SQLSERVER服务器链接连接(即sqlserver的跨库连接)_MySQL

SQLSERVER服务器链接连接(即sqlserver的跨库连接)_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 13:19:06
Original
1385 people have browsed it

bitsCN.com

一、如果你要访问的数据库,不在同一个服务器上,那么需要用服务器链接:

EXEC  sp_addlinkedserver@server='dblink名称',@srvproduct='',@provider='SQLOLEDB',@datasrc='目标服务器地址'GOEXEC sp_addlinkedsrvlogin'dblink名称','false', NULL,'用户名','密码'GO
Copy after login

小注:

1、上下两部分的'dblink名称'应该是一样的。

2、下面的用户名与密码应该是目标服务器上的用户名及密码。

3、使用的时候,只需要修改'dblink名称'、目标服务器地址、用户名及密码即可,其余的地方不需要修改。

4、执行sql server的跨库连接的时候,应该用sa账户登录(本地数据库也就是源数据库的sa账户登录)

图形化建立连接,如下图:

/

二、测试服务器链接是否成功的两种方式

1、SQL语句

--查询远程表select * from [dblink名称].远程数据库名.dbo.表
Copy after login

2、假如你新建的dblink名称为test,如下图:

/

创建好后,就在这个位置了,可以右键测试是否连通。

三、把本地表的数据,复制到远程表

insert into [Link].远程数据库名.dbo.表(列的列表)select 列from 本地表
Copy after login
bitsCN.com
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Problem with tp6 connecting to sqlserver database
From 1970-01-01 08:00:00
0
0
0
Unable to connect to SQL Server in Laravel
From 1970-01-01 08:00:00
0
0
0
Methods of parsing MYD, MYI, and FRM files
From 1970-01-01 08:00:00
0
0
0
SQLSTATE: User login failed
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template