Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enable Ad Hoc Distributed Queries

Status
Not open for further replies.

omacron

Technical User
Feb 5, 2002
149
Hi, Using MS SQL 2005

I am trying run the following script;
Code:
SELECT * into header FROM OPENROWSET('SQLOLEDB', 'IP Address';'sa';'Sa Password', 
'SELECT * FROM DBName.dbo.header')
I am getting this error;
Code:
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', see "Surface Area Configuration" in SQL Server Books Online.
I have try running this to enable it;
Code:
EXEC sp_configure 'Ad Hoc Distributed Queries', '1'
That gives me this error message;
Code:
Msg 15123, Level 16, State 1, Procedure sp_configure, Line 51
The configuration option 'Ad Hoc Distributed Queries' does not exist, or it may be an advanced option.

No I have found where to change this in Microsoft SQL Server 2005 => COnfiguration Tool => SQL Server 2005 Surface Area Configuration. This does fix my issue now but I need way to change this via a script so its much easier to configure future databases.
 
Code:
EXECUTE sp_configure 'show advanced options', 1 
RECONFIGURE WITH OVERRIDE 
GO 

EXECUTE  sp_configure 'Ad Hoc Distributed Queries', '1'
RECONFIGURE WITH OVERRIDE 
GO 

EXECUTE sp_configure 'show advanced options', 0 
RECONFIGURE WITH OVERRIDE 
GO

Denis The SQL Menace
--------------------
SQL Server Code,Tips and Tricks, Performance Tuning
Google Interview Questions





 
thank you very much that worked perfectly
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top