sql 跨域

时间:2023-03-10 02:04:50
sql 跨域

1. 开通分布式查询权限

exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure

2. 查询

select * from openrowset('SQLOLEDB','192.168.1.6';'sa';'',NETACS.dbo.tb_car) a
select * from opendatasource('SQLOLEDB','Data Source=192.168.1.6; User ID=sa; Password=123').NETACS.dbo.tb_car

3. 关闭

-- 注意执行顺序与 开通时 相反
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure

原文地址:http://www.veryhuo.com/a/view/16216.html