Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

parse a XML File into a SQL Table

$
0
0

Hello,

I want to parse following XML File into a SQL Table

below is the Query I am using, however all I get is a huge Table with NULLS

Is anyone able to help me further? 

Thanks,

XML File: http://pastebin.com/fZgwWaA5
SELECT
        f.c.value('IPAdd[1]', 'nvarchar(82)') [PLCLANIPAddress],
        n.c.value('PName[1]', 'nvarchar(82)') [PartNumber]
        p.c.value('IPAdd[1]', 'nvarchar(82)') [PLCAppName],
        q.c.value('PName[1]', 'nvarchar(82)') [PLCAppDescription]
FROM    @xml.nodes ('AB_Diag_PLCLANTMgr') a ( c )
		Outer Apply a.c.nodes ('PLCLAN_IP_PCat') d ( c )
		Outer Apply a.c.nodes ('PLCLAn_AppName_Desc') b ( c )
        OUTER APPLY d.c.nodes('IPAdd') f ( c )
        OUTER APPLY d.c.nodes('PName') n ( c )
        OUTER APPLY b.c.nodes('IPAdd') p ( c )
        OUTER APPLY b.c.nodes('PName') q ( c )


Viewing all articles
Browse latest Browse all 23857

Trending Articles