EXEC sp_addlinkedserver 'Testserver','','SQLOLEDB','192.168.1.221'
EXEC sp_addlinkedsrvlogin 'Testserver','false',NULL,'sa','xxxx'
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.[表名]
其他地址:http://www.cnblogs.com/w-y-f/archive/2012/05/07/2488474.html
链接服务器普通用户无法使用:引用地址:http://www.cnblogs.com/kerrycode/p/3793923.html
解决方案:添加master的public映射
USE master;
GO
GRANT EXECUTE ON XP_PROP_OLEDB_PROVIDER TO [erp];