Reading a value from the XML file and displaying it in SQL
DECLARE @MyXML XML
SET @MyXML = '
'
'print convert(nvarchar(500), @MyXML)
SELECT
a.b.value('a[1]/BibCodingSearch[1]/@CaseID','varchar(10)') AS CaseID,
a.b.value('a[1]/BibCodingSearch[1]/@BibCoding_Id','varchar(10)') AS BibCoding_Id,
a.b.value('a[1]/BibCodingSearch[1]/@Value','varchar(10)') AS Value,
a.b.value('a[1]/BibCodingSearch[1]/@Operator','varchar(10)') AS Operator
FROM @MyXML.nodes('xml') a(b)
UNION
SELECT
a.b.value('a[1]/BibCodingSearch[2]/@CaseID','varchar(10)') AS CaseID,
a.b.value('a[1]/BibCodingSearch[2]/@BibCoding_Id','varchar(10)') AS CaseIDBibCoding_Id,
a.b.value('a[1]/BibCodingSearch[2]/@Value','varchar(10)') AS Value,
a.b.value('a[1]/BibCodingSearch[2]/@Operator','varchar(10)') AS Operator
FROM @MyXML.nodes('xml') a(b)
Comments
Post a Comment