PCB SQL Server 代碼創建DbLink
阿新 • • 發佈:2018-08-28
password 數據 pan add style mtp sql call local
代碼如下:
DECLARE @serverName VARCHAR(100) DECLARE @ip VARCHAR(100) DECLARE @dbName VARCHAR(100) DECLARE @userName VARCHAR(100) DECLARE @userpassword VARCHAR(100) SET @serverName = ‘DbLinkName‘ --db鏈接名 SET @ip = ‘120.79.36.65‘ --需連接服務器的IP SET @dbName = ‘DbName‘ --需連接服務器的數據庫名 SET @userName =‘sxi‘ --需連接服務器的帳號 SET @userpassword = ‘***‘ --需連接服務器的密碼 EXEC master.dbo.sp_addlinkedserver @server = @serverName, @srvproduct=@serverName, @provider=N‘SQLNCLI‘, @datasrc=@ip, @catalog=@dbName EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=@serverName,@useself=N‘False‘,@locallogin=NULL,@rmtuser=@userName,@rmtpassword=@userpassword EXEC master.dbo.sp_serveroption @server=@serverName, @optname=N‘rpc‘, @optvalue=N‘true‘ EXEC master.dbo.sp_serveroption @server=@serverName, @optname=N‘rpc out‘, @optvalue=N‘true‘
PCB SQL Server 代碼創建DbLink