linkserver用法

linkserver用法

例子1:

exec sp_addlinkedserver 'srv_lnk','','SQLOLEDB','172.17.32.123'

exec sp_addlinkedsrvlogin 'srv_lnk','false',null,'sa','135117'



select * from srv_lnk.mydb.dbo.InvGen


例子2:

新建linkserver,先在sms里新建个linkserver,然后create到文本框

--先建linkserver
EXEC master.dbo.sp_addlinkedserver @server = N'TEST1', @srvproduct=N'172.17.32.123',@provider=N'SQLNCLI',@datasrc=N'172.17.32.123', @catalog=N'bdg'
--再建登陆
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'TEST1',@useself=N'False',@locallogin=N'sa',@rmtuser=N'sa',@rmtpassword=N'135117'

GO

你可能感兴趣的:(SQLServer)