当我在SQL Server 2000中使用OPENROWSET运行查询时,它可以工作。
但SQL Server 2008中的相同查询生成以下错误:
SQL Server阻止访问组件“Ad Hoc Distributed Queries”的STATEMENT“OpenRowset / OpenDatasource”,因为此组件是作为此服务器的安全configuration的一部分而closures的。 系统pipe理员可以使用sp_configure启用“Ad Hoc Distributed Queries”
我试着跑
EXEC sp_configure 'show advanced options', 1 RECONFIGURE GO EXEC sp_configure 'ad hoc distributed queries', 1 RECONFIGURE GO
但是任何尝试运行RECONFIGURE都会导致错误:
Msg 5808, Level 16, State 1, Line 1 Ad hoc update to system catalogs is not supported.
如何在SQL Server 2008 R2中启用Ad Hoc分布式查询?
Windows NT 6.1(Build 7601:Service Pack 1)上的Microsoft Corporation标准版(64位) 注意 :Microsoft SQL Server 2008 R2(SP1) – 10.50.2550.0(X64)Jun 11 2012 16:41:53 (pipe理程序)
从这里: http : //sqlserverpedia.com/blog/database-design/error-message-ad-hoc-update-to-system-catalogs-is-not-supported/
首先运行这个:
EXEC sp_configure 'allow updates', 0 RECONFIGURE
或者将您的RECONFIGURE语句更改为RECONFIGURE WITH OVERRIDE :
EXEC sp_configure 'show advanced options', 1 RECONFIGURE WITH OVERRIDE --really reconfigure GO EXEC sp_configure 'ad hoc distributed queries', 1 RECONFIGURE WITH OVERRIDE --really reconfigure GO