From: M A Srinivas on
Following query ,emits error

SELECT TOP 1000 total_worker_time/execution_count AS [Avg CPU Time],
deqp.dbid,deqp.objectid,deqp.number,deqp.encrypted
FROM sys.dm_exec_query_stats AS qs
CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) deqp
GO

-- Error SQL Server 2008 Developer SP1
Msg 9437, Level 16, State 1, Line 1
XML parsing: line 1, character 3312, duplicate attribute


-- Error SQL Server 2005 Developer SP2
Msg 9437, Level 16, State 1, Line 1
XML parsing: line 1, character 1513, duplicate attribute
From: Erland Sommarskog on
M A Srinivas (masri999(a)gmail.com) writes:
> Following query ,emits error
>
> SELECT TOP 1000 total_worker_time/execution_count AS [Avg CPU Time],
> deqp.dbid,deqp.objectid,deqp.number,deqp.encrypted
> FROM sys.dm_exec_query_stats AS qs
> CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) deqp
> GO
>
> -- Error SQL Server 2008 Developer SP1
> Msg 9437, Level 16, State 1, Line 1
> XML parsing: line 1, character 3312, duplicate attribute
>
>
> -- Error SQL Server 2005 Developer SP2
> Msg 9437, Level 16, State 1, Line 1
> XML parsing: line 1, character 1513, duplicate attribute

You could try using dm_exec_query_plan_text instead. It is possible
for an XML plan to go beyond what the xml data type supports.


--
Erland Sommarskog, SQL Server MVP, esquel(a)sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx