29 Mar 2010

SQL Server 2008 Ad Hoc Queries Distributed

Configure ad hoc queries
(this needs to be done on the server you want to run the queries from).

sp_configure 'show advanced options', 1
reconfigure 


sp_configure 'Ad Hoc Distributed Queries', 1  
reconfigure 

I normally set these back to 0 afterwards as I use ad hoc queries rarely.

Sample ad hoc query 

SELECT RS.*
FROM OPENROWSET(
  'SQLNCLI',
  'SERVER=arkleserverws,6521;UID=username;PWD=password;DATABASE=dbname;',
  'SELECT Top (10) * FROM dbname.dbo.tablename'
) AS RS;




No comments:

Post a Comment