--To view the current link situation:Select * fromsys.servers;--use Sp_helpserver to display the available serversExecsp_helpserver--Delete a link that already existsExecSp_droplinkedsrvlogin server aliases,NullExecsp_dropserver Server Aliases--use sp_addlinkedserver to add linksEXECsp_addlinkedserver@server='192.168.2.66',--the server alias being accessed (used to directly use the target server IP, or to take an individual name such as: JOY)@srvproduct="',@provider='SQLOLEDB',@datasrc='192.168.2.66' --the server to access--use sp_addlinkedsrvlogin to add user login linksEXECsp_addlinkedsrvlogin'192.168.2.66',--the server alias being accessed (if you use the alias joy in sp_addlinkedserver above, this is joy too)'false',NULL,'SA',--Account Number'test123' --PasswordUse an example (access the database music on the target server to view the contents of the table test): If the alias is the target server IP, 192, when the link is established.168.2. theThen:Select * from [192.168.2.66].[Music]. Dbo.test If the alias is joy when the link is established, then:Select * from [JOY].[Music]. Dbo.test may encounter problems:execSp_dropserver'JOY'execution failure, error message: There is still a server'JOY'telnet or link to login. Workaround:execSp_droplinkedsrvlogin'JOY',NULLexecSp_dropserver'JOY'
Source: http://blog.sina.com.cn/s/blog_4c197d4201017aoq.html
Using sp_addlinkedserver to implement remote database linking