以下查詢在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