SQL Server XML declares namespace

I would like to have multiple namespaces available by default when running XQuery in SQL Server 2005, is this possible?

For example, I would like to do the following:

select * from TableWithXML
where
FieldWithXML.exist(
declare namespace nsp="http://www.example.com/exampleNamespace";
nsp:root/nsp:childnode) = 1

      

Without having to re-create the namespace every time, so that SQL will recognize nsp without me including the prologue every time.

Thoughts?

+2


source to share


1 answer


Namespaces xml

and xsi

are the only predefined namespaces that you do not need to declare yourself. All other namespaces must be explicitly declared in every request.

There are two ways to declare namespaces:



  • via a statement declare

    inside XQuery.
  • via the WITH XMLNAMESPACES clause in the TSQL statement.
+1


source







All Articles