August 24, 2013 at 12:01 am
Hi All ,
why below syntax is giving me error ..
; with xmlnamespaces ('http://my/schemas/20120701' as cmp)
select cast('<cmp:O b="16" />' as xml)
and below is working fine..
; with xmlnamespaces ('http://my/schemas/20120701' as cmp)
select cast('<O b="16" />' as xml)
Thanks,
Saurabh
August 24, 2013 at 3:30 am
Because
<cmp:O b="16" />
is not a valid XML document. It doesn't help to add WITH XMLNAMESPACES; the document is still not valid.
You can use WITH XMLNAMESPACES when you want to construct XML documents with FOR XML. You can also use it with the XML type methods to pre-declare namespaces, so that you don't have to do it in the prologue.
See http://technet.microsoft.com/en-us/library/ms177400.aspx.
[font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply