USE master
GO
--To use named parameters:
EXEC sp_addlinkedserver @server = 'AA\BB', @provider = 'MSDASQL', @provstr = 'DRIVER={SQL Server};SERVER=AA\BB;UID=sa;PWD=;'
GO
-- OR to use no named parameters
USE master
GO
EXEC sp_addlinkedserver 'AA\BB', '', 'MSDASQL', NULL, NULL, 'DRIVER={SQL Server};SERVER=MyServer;UID=sa;PWD=;'
GO
--- sp_dropserver 删除创建的 link
exec sp_dropserver ''AA\BB' '
--查看创建的 link
exec sp_helpserver
--查看
select * from [AA\BB].[数据库名].dbo.[表名]