Using a variable as an xpath value in xml.query
i trying use variable xpath when query statement on xml document in sql server 2008. have tried
declare @str varchar(8000)
set @str = 'acord/insurancesvc/persautopolicyaddrq/producer/producerinfo/contractnumber'
select @mydoc.query(@str)
returns
msg 8172, level 16, state 1, line 11
argument 1 of xml data type method "query" must string literal.
, have tried
declare @str varchar(8000)
set @str = 'acord/insurancesvc/persautopolicyaddrq/producer/producerinfo/contractnumber'
select @mydoc.query('sql:variable("@str")')
returns
acord/insurancesvc/persautopolicyaddrq/producer/producerinfo/contractnumber
have ideas on how can it?
thanks!
michael
declare @str varchar(8000)
set @str = 'acord/insurancesvc/persautopolicyaddrq/producer/producerinfo/contractnumber'
select @mydoc.query(@str)
returns
msg 8172, level 16, state 1, line 11
argument 1 of xml data type method "query" must string literal.
, have tried
declare @str varchar(8000)
set @str = 'acord/insurancesvc/persautopolicyaddrq/producer/producerinfo/contractnumber'
select @mydoc.query('sql:variable("@str")')
returns
acord/insurancesvc/persautopolicyaddrq/producer/producerinfo/contractnumber
have ideas on how can it?
thanks!
michael
dynamic sql:
rbarryyoung
declare @str varchar(8000) set @str = 'select @mydoc.query(''acord/insurancesvc/persautopolicyaddrq/producer/producerinfo/contractnumber'')' exec (@str)
know, stinks.rbarryyoung
SQL Server > SQL Server XML
Comments
Post a Comment