1. 程式人生 > >SqlServer通過sql語句訪問指定IP地址的資料庫

SqlServer通過sql語句訪問指定IP地址的資料庫

1.啟用 'Ad Hoc Distributed Queries'

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

2.查詢

demo:SELECT * FROM OPENDATASOURCE
( 
'SQLOLEDB','
DataSource=192.168.120.191;
User ID=sa;
Password=123456'
).FuelDataMgt.dbo.Operator 

3.關閉 'Ad Hoc Distributed Queries'

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