I'm trying to query XML while ignoring namespaces, because the result set has multiple namespaces. I've gotten to the DataSets node, but I can't figure out how to get out the multiple DataSourceName/CommandType/CommandText. Ideally I want:
DataSetName DataSourceName CommandType CommandText
SQLDS SQLDS StoredProcedure ReportProc_aaaaa
SQLDS SQLDS StoredProcedure ReportProc_lalala
Help greatly appreciated.
DECLARE @xmltable TABLE (myxml XML)
INSERT INTO @xmltable
SELECT
'<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<DataSources>
<DataSource Name="SQLDS">
<rd:DataSourceID>32e83b35-434d-4808-b685-ada14accd0e7</rd:DataSourceID>
<DataSourceReference>SQLDS</DataSourceReference>
</DataSource>
</DataSources>
<DataSets>
<DataSet Name="SQLDS">
<Query>
<DataSourceName>SQLDS</DataSourceName>
<CommandType>StoredProcedure</CommandType>
<CommandText>ReportProc_ServerPerformanceGroup</CommandText>
</Query>
</DataSet>
<DataSet Name="GroupDetails">
<Query>
<DataSourceName>SQLDS</DataSourceName>
<CommandType>StoredProcedure</CommandType>
<CommandText>ReportProc_lalala</CommandText>
</Query>
</DataSet>
</DataSets>
</Report>'
SELECT myxml.value('(/*:Report/*:DataSets)[1]','varchar(100)') FROM @xmltable