SELECT
XMLTable.actions.value('(@name)', 'varchar(100)') Name,
XMLTable.actions.value('(@started)', 'datetime') [Started],
XMLTable.actions.value('(@started)', 'datetime') +
convert(float, replace (replace (XMLTable.actions.value('(@elapsedWithChildren)', 'varchar(100)'),'PT',''),'S','')) / (60 * 60 * 24) Ended, --dodgy floating point rounding errors
convert(float, replace (replace (XMLTable.actions.value('(@elapsed)', 'varchar(100)'),'PT',''),'S','')) Elapsed,
convert(float, replace (replace (XMLTable.actions.value('(@elapsedWithChildren)', 'varchar(100)'),'PT',''),'S','')) ElapsedWithChildren,
XMLTable.actions.value('@moduleId','varchar(100)') moduleid,
XMLTable.actions.value('@actionCount','int') actionCount,
XW_PK, XW_ExeVersion, XW_EnterpriseCode, XW_DatabaseCode, XW_CompanyCode, ExportType
FROM StmUsage
CROSS APPLY xw_rawData.nodes('declare namespace pd="http://cargowise.com/ediEnterprise/2011/10/11/systemUsage.xsd";
/pd:performanceMeasurement/pd:action') XMLTable(actions)
cross join (select 'Elapsed' ExportType union select 'ElapsedWithChildren') ExportTypeAlias
Легко как!