以下查询在SQL Server 2008中运行,但它在SQL Server 2012中不起作用。为什么?发现问题查询
SELECT TOP 20
total_worker_time/execution_count AS Avg_CPU_Time,
Execution_count,
total_elapsed_time/execution_count AS AVG_Run_Time,
total_elapsed_time,
(SELECT
SUBSTRING(text, statement_start_offset/2 + 1, statement_end_offset)
FROM sys.dm_exec_sql_text(sql_handle))
AS Query_Text
FROM sys.dm_exec_query_stats
ORDER BY Avg_CPU_Time DESC
必须抛出一些error.you可以打破查询分成几个部分,并检查哪些特定的查询不working.May是新服务器中的权限问题。 – KumarHarsh
你正在观察的错误/问题是什么? – TheGameiswar
您不能通过'Avg_CPU_Time'进行排序,因为它是计算值的别名,请使用'ORDER BY 1 DESC'而不是 – CeOnSql