April 30, 2009 at 6:05 am
I am trying to use a variable as the xpath when I do a query statement on an XML document in SQL Server 2008. I have tried
DECLARE @STR varchar(8000)
SET @STR = 'ACORD/InsuranceSvc/PersAutoPolicyAddRq/Producer/ProducerInfo/ContractNumber'
select @myDoc.query(@str)
which returns
Msg 8172, Level 16, State 1, Line 11
The argument 1 of the XML data type method "query" must be a string literal.
and I have tried
DECLARE @STR varchar(8000)
SET @STR = 'ACORD/InsuranceSvc/PersAutoPolicyAddRq/Producer/ProducerInfo/ContractNumber'
select @myDoc.query('sql:variable("@str")')
which returns
ACORD/InsuranceSvc/PersAutoPolicyAddRq/Producer/ProducerInfo/ContractNumber
Does anyone have any ideas on how I can do it?
Thanks!
Michael
April 30, 2009 at 5:05 pm
The only thing that comes to mind is dynamic sql.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy