I have this table
declare @temp_xml table
(
question_id int,
question_xml xml
)
insert into @temp_xml(question_id, question_xml)
values(51, '<qst qodm="Horizontal" oprm="New Line" oph="25" opw="200" stext="" filepath="" peqid="-1" peaid="-1" pipeqtype="1" rad="False"><cps><qvs qvid="V1" qvt="Required" qvem="Please choose at least one answer." /><qvs qvid="V15" qvt="UK Phone Number " qvem="Is not a correct phone format." /></cps><branch><![CDATA[]]></branch></qst>'
),
(52,
'<qst qodm="Horizontal" oprm="New Line" oph="25" opw="200" stext="" filepath="" peqid="-1" peaid="-1" pipeqtype="1" rad="False"><cps><qvs qvid="V1" qvt="Required" qvem="Please choose at least one answer." /><qvs qvid="V5" qvt="US/Canada Phone Number " qvem="Is not a correct phone format." /></cps><branch><![CDATA[]]></branch></qst>'
)
select * from @temp_xml
Now I want to show like this .
Question_id qvt qvem
51, Required, Please choose at least one answer.
51, UK Phone Number, Is not a correct phone format.
52, Required, Please choose at least one answer.
52, US/Canada Phone Number, Is not a correct phone format.
any one can help me out ?
Thanks.
I would avoid the old
openxmlAPI altogether and use the new XQuery style in SQL Server 2005 and newer.In your case, this would be something like:
This produces an output like this (I included the “QVID” column, just to show what really gets selected):