In Microsoft SQL Server 2008, how can I generate specific XML tags? -
i not familiar generating xml code sql. after doing research, think need use statement like: for xml explicit
, for xml raw
or for xml auto
, when run on auto
, output row this:
<student externalstudentid1="100003" lastname="smith" externalsiteid="place"/>
that close need, has have specific opening , closing tags like:
<student externalstudentid1="100003" externalsiteid="place"></student>
when tried using elements
, raw
, or path
ended opening , closing tags of elements. explicit
threw errors , require rewriting entire select statement. can help? here code:
select [externalstudentid1] studid, ( select [externalstudentid1],[externalstudentid2],[socialsecuritynumber],sbl.fn_tosbldate ( [birthdate]) [birthdate],[lastname],[firstname],[middlename],[informalname],[nametitle] ,[namesuffix],[externalcampusid],[externalsiteid] sbl.[student] student student.externalstudentid1=stud.externalstudentid1 xml auto ) sbldata sbl.[student] stud stud.[excludefromsbl] =0
to generate both open , close tag can add empty inner text node. example.
select externalstudentid1 '@externalstudentid1', externalsiteid '@externalsiteid', ... '' 'text()' -- empty string inner text added sbl.[student] xml path('student')
Comments
Post a Comment