SQL Server 2005 XML to table -
I am using classic ASP and I have a Proc in a varchar (ado data type) in an XML data column.
The XML looks like this:
& lt; Document Controls & gt; & Lt; Document documentGUID = "{B49654E7- 9AAF2-4B89-AF8F-5146F7CD4911}" Grader FYC = "5907" & gt; & Lt; Criterion cnumber = "1" rank = "3" /> & Lt; Criterion cnumber = "3" rank = "3" /> & Lt; / Documents & gt; & Lt; / DocumentCriteria & gt; '
I have a table that looks like this:
DocumentGUID | GraderFYC | Cnumber | Rank {guid} | 5907 | 1 | 3 {guide} | 5907 | 3 | 3
How can I do this in a process? Is the Adverption Type OK in the ADO Connection?
So do you have a stored procedure that takes a VARCHAR? Ok, something like this will work:
Start the optional process as dbo.YourProcedure (@ data VARCHAR (2000)) @ XmlContent XML SET @XmlContent = CAST (@data as XML) INSERT Dbo.YourTable (DocumentGUID, GraderFYC, Cnumber, Rank) SELECT @ XmlContent.value ('(/ DocumentCriteria / Document / @ documentGUID) [1]', 'Vertical (50)'), @ XmlContent.value ('(/ DocumentCriteria / 'GatterFYC' [1] ',' Int '), Doctor Crit.Value (' (CNNM) [1] ',' Int ') AS' Songbear ', Dr.C.Crit.Value (' (@ Rank) from 'rank' to @ XmlContent.nodes ('/ DocumentCriteria / Document / criterion') AS Doctor (Crit) END
Select this DocumentGUID
and GraderFYC
from your single on the & lt; document & gt;
tag and then all include & lt; Criteria & gt;
Nodes to capture the rest of the data.
Comments
Post a Comment