I want to SELECT some data from a remote SQL Server database which has "Ad Hoc Distributed Queries" enabled. The remote server is not a linked server to my local instance and its not in my ODBC data sources. I didn't think it had to be anyway.
However I don't understand how to get to it. I have tried this (replacing the xx.xx.xx.xx
part with the IP address of the remote server):
SELECT *
FROM OPENDATASOURCE(
'SQLNCLI',
'Data Source=xx.xx.xx.xx\MSSQLSERVER;User ID=SA;Password=SA;').MainDB.dbo.Product
I get the following error:
Msg 15281, Level 16, State 1, Line 1: SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', search for 'Ad Hoc Distributed Queries' in SQL Server Books Online.
The remote server has 'Ad Hoc Distributed Queries' for sure 100%. What am I missing? I turned SQL Server Browser on the remote server as well.