Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Variable in XQUERY

From: "Joe Fawcett" <joefawcett@---------.------>
To: NULL
Date: 5/21/2008 8:15:00 AM

"Ganesh Muthuvelu" <GaneshMuthuvelu@d...> wrote in 
message news:CCB34C12-0D42-445E-A85F-F63656A889F1@m......
> Hello,
> I have a XML as below:
>
> declare @doc2 xml
> SET @doc2 = '<?xml version="1.0" ?>
> <p1: Domains_and_Emails xmlns:p1="LDAP">
>  <Domain>
>    <UnixEmail>
>      <uid>info</uid>
>      <Password>xyz</Password>
>      <EmailAccount>info@x...</EmailAccount>
>    </UnixEmail>
> </Domain>
> </p1: Domains_and_Emails>'
>
> and I am using the xml.nodes function to get the XML at the required
> position as below:
>
> SELECT
>  tab.col.value('uid[1]','VARCHAR(20)')AS uid
>  FROM @doc2.nodes('declare namespace p1="LDAP"; //p1:
> Domains_and_Emails/Domain[1]/UnixEmail[1]') tab(col)
>
> In the above example, how would I replace the static literal "//p1:
> Domains_and_Emails/Domain[1]/UnixEmail[1]" with a variable?. basically, I
> need to pass a value for that string via a variable..
>
> Can someone help?
>
> Thanks,
> Ganesh
>
>
As far as I understaqnd you can't, the standard workaround in to construct 
the SQL statement dynamically and execute using sp_ExecuteSQL.
You may wish to try microsoft.public.sqlserver.xml for these types of 
questions.

-- 

Joe Fawcett (MVP - XML)

http://joe.fawcett.name




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent