[mssql/sql server]SQL生成另外一个服务器的连接并在本机器上查询
--exec sp_addlinkedserver 'ITSV ', ' ', 'SQLOLEDB ', '远程服务器名或ip地址 '
--exec sp_addlinkedsrvlogin 'ITSV ', 'false ',null, '用户名 ', '密码
exec sp_addlinkedserver 'opuhis', '', 'SQLOLEDB ', '127.0.0.1'
exec sp_addlinkedsrvlogin 'opuhis', 'false',null, 'sa', 'pass1'
go
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
go
create view v_his_login_user
as
-- [远程连接].[库名].[dbo].表
select * from opuhis.[dbo].login_user
go
create view v_his_tech_Apply
as
select * from opuhis.[dbo].tech_Apply
go
------------------------------
语句写错了。opuhis.[dbo].login_user应该是opuhis.opuhis.[dbo].login_user