DetailPage-MSS-KB

Microsoft small business knowledge base

Article ID: 2587511 - Last Review: October 17, 2011 - Revision: 1.0

On This Page

Microsoft distributes Microsoft SQL Server 2008 R2 Service Pack 1 (SP1) fixes as one downloadable file. Because the fixes are cumulative, each new release contains all the hotfixes and all the security updates that were included with the previous SQL Server 2008 R2 Service Pack 1 (SP1) update release.

SYMPTOMS

When a SQL Server performance condition alert is raised in Microsoft SQL Server 2008 R2, you might receive the following error message:
Msg 512, Level 16, State 1, Procedure sp_sqlagent_get_perf_counters, Line 40
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
Additionally, the error message is logged in the SQL Server Agent error log in this situation.

Note This issue also occurs in Microsoft SQL Server 2008.

CAUSE

This issue occurs because the subquery of the msdb.dbo.sp_sqlagent_get_perf_counters system stored procedure calculates the value of a counter incorrectly.

The subquery lacks an inner join relationship for the [object_name] column in the condition of the subquery. Therefore, multiple rows are incorrectly returned, and the issue that is mentioned in the "Symptoms" section occurs.

Note The msdb.dbo.sp_sqlagent_get_perf_counters system stored procedure runs when a SQL Server performance condition alert is raised.

RESOLUTION

Cumulative update information

Cumulative update package 3 for SQL Server 2008 R2 SP1

The fix for this issue was first released in cumulative update package 3. For more information about how to obtain this cumulative update package for SQL Server 2008 R2 SP1, click the following article number to view the article in the Microsoft Knowledge Base:
2591748  (http://support.microsoft.com/kb/2591748/ ) Cumulative update package 3 for SQL Server 2008 R2 SP1
Note Because the builds are cumulative, each new update release contains all the hotfixes and all the security updates that were included with the previous SQL Server 2008 R2 SP1 update release. We recommend that you consider applying the most recent update release that contains this hotfix. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
2567616  (http://support.microsoft.com/kb/2567616/ ) The SQL Server 2008 R2 builds that were released after SQL Server 2008 R2 SP1 was released


WORKAROUND

To work around this issue, update the subquery of the msdb.dbo.sp_sqlagent_get_perf_counters system stored procedure. To do this, add the following condition to the WHERE clause of the four subqueries that are used in the [value] column calculation:
(spi1.[object_name] = spi2.[object_name])
After you add the condition, the subqueries resemble the following:
SELECT CASE spi2.cntr_value WHEN 0 THEN 1 ELSE spi2.cntr_value END
FROM sys.dm_os_performance_counters spi2
WHERE (spi1.[object_name] = spi2.[object_name])
AND (spi1.counter_name + ' ' = SUBSTRING(spi2.counter_name, 1, PATINDEX('% Base%', spi2.counter_name)))
AND (spi1.instance_name = spi2.instance_name)
AND (spi2.cntr_type = @perfTypeLargeRawBase

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

APPLIES TO
  • Microsoft SQL Server 2008 Enterprise
  • Microsoft SQL Server 2008 Enterprise Evaluation
  • Microsoft SQL Server 2008 R2 Datacenter
  • Microsoft SQL Server 2008 R2 Developer
  • Microsoft SQL Server 2008 R2 Enterprise
Keywords: 
kbqfe kbfix kbexpertiseadvanced kbsurveynew KB2587511
Share
Additional support options
Ask The Microsoft Small Business Support Community
Contact Microsoft Small Business Support
Find Microsoft Small Business Support Certified Partner
Find a Microsoft Store For In-Person Small Business Support