原文網址
--Add DB Link Server
EXEC sp_addlinkedserver
@server = 'F6', --Server Name
@srvproduct = 'MS SQL',
@datasrc = '192.168.1.1' , --Server IP
@provider = 'SQLNCLI'
--Remove DB Link Server
EXEC sp_dropserver
@server = 'F6' --Server Name
--Add Login User and Password
EXEC sp_addlinkedsrvlogin
@rmtsrvname = 'F6' , --Server Name
@useself = 'false' ,
@locallogin = NULL ,
@rmtuser = 'sa' , --User
@rmtpassword = 'sasa' --Password
--Add DB Link Server
EXEC sp_addlinkedserver
@server = 'F6', --Server Name
@srvproduct = 'MS SQL',
@datasrc = '192.168.1.1' , --Server IP
@provider = 'SQLNCLI'
--Remove DB Link Server
EXEC sp_dropserver
@server = 'F6' --Server Name
--Add Login User and Password
EXEC sp_addlinkedsrvlogin
@rmtsrvname = 'F6' , --Server Name
@useself = 'false' ,
@locallogin = NULL ,
@rmtuser = 'sa' , --User
@rmtpassword = 'sasa' --Password
--Query DB Link Server
select * from sys.servers
--Query DB Link Server
select * from sys.servers
--Query Login User
select * from sys.linked_logins
--Query Login User
select * from sys.linked_logins
--Query DB Link Data
select * from [F6].[database].[dbo].[table]
--select * from [server name].[database name].[owner name].[table name]
--Query DB Link Data
select * from [F6].[database].[dbo].[table]
--select * from [server name].[database name].[owner name].[table name]