I have not seen an xml file similar to this one with the current postings. The file I am trying to work with is the Project.params SSIS file that looks like this:
<SSIS:Parameters xmlns:SSIS="www.microsoft.com/SqlServer/SSIS">
<SSIS:Parameter SSIS:Name="PackageVersion">
<SSIS:Properties>
<SSIS:Property SSIS:Name="ID">{673faa65-53ec-483d-8af2-960987977177}</SSIS:Property>
<SSIS:Property SSIS:Name="CreationName" />
<SSIS:Property SSIS:Name="Description">The package version</SSIS:Property>
<SSIS:Property SSIS:Name="IncludeInDebugDump">0</SSIS:Property>
<SSIS:Property SSIS:Name="Required">0</SSIS:Property>
<SSIS:Property SSIS:Name="Sensitive">0</SSIS:Property>
<SSIS:Property SSIS:Name="Value">1.0.0</SSIS:Property>
<SSIS:Property SSIS:Name="DataType">18</SSIS:Property>
</SSIS:Properties>
</SSIS:Parameter>
<SSIS:Parameter SSIS:Name="Debug">
<SSIS:Properties>
<SSIS:Property SSIS:Name="ID">{501b3d7c-f7ac-429b-bb2d-c314649d9c98}</SSIS:Property>
<SSIS:Property SSIS:Name="CreationName" />
<SSIS:Property SSIS:Name="Description">Determines whether the package is ran in debug mode</SSIS:Property>
<SSIS:Property SSIS:Name="IncludeInDebugDump">0</SSIS:Property>
<SSIS:Property SSIS:Name="Required">0</SSIS:Property>
<SSIS:Property SSIS:Name="Sensitive">0</SSIS:Property>
<SSIS:Property SSIS:Name="Value">true</SSIS:Property>
<SSIS:Property SSIS:Name="DataType">3</SSIS:Property>
</SSIS:Properties>
</SSIS:Parameter>
</SSIS:Parameters>
I tried to follow the post here: Read xml file in SQL Server just not having success in getting the data retrieved. Here is the code I have so far:
;WITH rs (xmldata) AS
(
SELECT TRY_CAST(BulkColumn AS XML) AS BulkColumn
FROM OPENROWSET(BULK 'C:\Software\Project.params', SINGLE_BLOB) AS x
),cte AS
(
SELECT a.value('@Parameter', 'NVARCHAR(50)') AS Parameter
, c.value('@ID','NVARCHAR(50)') AS ID
, c.value('@CreationName','NVARCHAR(50)') AS CreationName
, c.value('@Description','NVARCHAR(100)') AS [Description]
, c.value('@IncludeInDebugDump','INT') AS IncludeInDebugDump
, c.value('@Required','INT') AS [Required]
, c.value('@Sensitive','INT') AS Sensitive
, c.value('@Value','NVARCHAR(10)') AS [Value]
, c.value('@DataType','INT') AS DataType
FROM rs AS tbl
CROSS APPLY tbl.xmldata.nodes('/Parameters') AS t1(a)
OUTER APPLY t1.a.nodes('/Parameter') AS t2(b)
OUTER APPLY t2.b.nodes('/Properties') AS t3(c)
OUTER APPLY t3.c.nodes('/Property') AS t4(d)
)
select * from cte
This runs successfully (the first cte rs pulls the data correctly) but the second cte returns no data. No errors, I get the columns in the Results, just no rows. Any guidance would be greatly appreciated.