Professional Documents
Culture Documents
Syntax: Openxml (Idoc Int (In), Rowpattern Nvarchar (In), (Flags Byte (In) ) ) (With (Schemadeclaration - Tablename) )
Syntax: Openxml (Idoc Int (In), Rowpattern Nvarchar (In), (Flags Byte (In) ) ) (With (Schemadeclaration - Tablename) )
OPENXML can be used in TransactSQL statements in which rowset providers such as a table, view
Syntax:
OPENXML( idoc int [ in] , rowpattern nvarchar [ in ] , [ flags byte [ in ] ] )
[ WITH ( SchemaDeclaration | TableName ) ]
doc
Is the document handle of the internal representation of an XML document. The
internal representation of an XML document is created by
calling sp_xml_preparedocument.
Rowpattern
Is the XPath pattern used to identify the nodes (in the XML document whose handle is
passed in the idocparameter) to be processed as rows.
Flags
Indicates the mapping that should be used between the XML data and the relational
rowset, and how the spill-over column should be filled. flags is an optional input
parameter, and can be one of the following values.
Byte value
Description
Example :
USE PUBS
DECLARE @xml_text VARCHAR(4000), @i INT
au_id="172-32-1176"
au_lname="White"
au_fname="Johnson"
phone="408 496-7223"
address="10932 Bigge Rd."
city="Menlo Park"
state="CA"
zip="94025"
contract="1"/>
<authors
au_id="213-46-8915"
au_lname="Green"
au_fname="Marjorie"
phone="415 986-7020"
address="309 63rd St. #411"
city="Oakland"
state="CA"
zip="94618"
contract="1"/>
<authors
au_id="238-95-7766"
au_lname="Carson"
au_fname="Cheryl"
phone="415 548-7723"
address="589 Darwin Ln."
city="Berkeley"
state="CA"
zip="94705"
contract="1"/></root>'
Results:
au_id
172-32-
au_lnam
au_fnam
White
Johnson
1176
213-46-
Green
Marjorie
8915
238-957766
Carson
Cheryl
phone
Address
city
stat
zip
408 496-
10932 Bigge
Menlo
7223
Rd.
Park
415 986-
Oakland
7020
#411
415 548-
7723
CA
contrac
t
9402
CA
9461
Berkeley
CA
9470
5