title: SQL Server xp_regread access denied
body: <p>I have a client that is having an 'Access Denied' to a call to xp_regread (trying to find the database path), but I cannot seem to reproduce this. I have tried running the following</p>
  
  <pre><code>REVOKE execute on xp_regread to public
  </code></pre>
  
  <p>But it still works. I also found some articles on SQL Server 2000 problems (http://support.microsoft.com/kb/887165) but the clients server is 2005. Any ideas on how to go about fixing this problem.</p>
  
  <p>Edit: I have tried the following</p>
  
  <pre><code>USE MASTER
  GO
  
  REVOKE execute on xp_regread to public
  GO
  
  DECLARE @InstanceName nvarchar( 128 )
  SET @InstanceName = ISNULL( CONVERT( nvarchar( 128 ), SERVERPROPERTY( 'InstanceName' ) ), N'MSSQLSERVER' )
  DECLARE @InstanceKey nvarchar( 128 )
  EXECUTE master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\Microsoft SQL Server\Instance Names\SQL\', @InstanceName, @InstanceKey OUTPUT
  
  print @InstanceName
  print @InstanceKey
  </code></pre>
  
  <p>But it is still working. To be clear, I am trying to reproduce an issue where the call does NOT work. Revoking permissions was one way that I read should do it, but it still works for me.</p>