Question: 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?

Answer: 
Read through this:

[Link](https://learn.microsoft.com/en-us/archive/blogs/psssql/troubleshooting-sql-server-2005-2008-performance-counter-collection-problems)

The exact instructions are not 100% correct. You need to do this, assuming you are using the default instance:

```
unlodctr MSSQLSERVER
lodctr perf-MSSQLSERVERsqlperf.ini
lodctr /T:MSSQLSERVER

```

Then reboot.
If you're running a 32-bit version of SQL Server on a 64-bit installation of Windows you need to use the 32-bit version of Performance Monitor to view the counters as explained in [this MSDN Blog](http://blogs.msdn.com/b/docast/archive/2014/08/25/issues-with-sql-data-collection-using-performance-monitor-user-defined-data-collector-set.aspx). Do so using either of these methods:

1. Run `perfmon.exe` from the `%windir%\SysWOW64` folder
2. Run the command `mmc /32 perfmon.msc`

Also, make sure you're running SQL Server with the latest Service Pack and Hotfixes. [MSKB article 2708726](https://support.microsoft.com/en-us/kb/2708726) describes an issue where Performance Monitor .dll files don't get updated properly when applying updates to SQL Server 2008 R2 or SQL Server 2012.