Sql-server – How to revive SQL Server 2008 R2 performance counters

perfmonsql serversql-server-2008-r2

I'm running SQL Server 2008 R2 Developer on Windows 7 x64, as the default instance. For some reason, SQL Server's performance counters seem to have disappeared. SELECT * FROM sys.dm_os_performance_counters returns zero rows.

I tried running lodctr /T:perf-MSSQLSERVERsqlctr.ini. Although it completed without errors, it didn't fix anything, even after restarting the Remote Registry service. In fact, the counters are now missing from perfmon. unlodctr MSSQLSERVER still says that the counters are not installed, but lodctr /Q:MSSQLSERVER says they're present and enabled. Regular Windows and .NET counters are working fine.

In the Windows Error log, I'm seeing Error 8317:

Cannot query value 'First Counter' associated with registry key
'HKLM\SYSTEM\CurrentControlSet\Services\MSSQLSERVER\Performance'. SQL
Server performance counters are disabled.

I suspect the problem may have been triggered by an installation of SQL 2012 RC0 that failed. Any suggestions for how to recover, short of reinstalling SQL Server 2008 R2?

Best Answer

Have a try with lodctr /R, it will rebuild all performance counters from informations stored in registry.