dynamic xpath in xml.query() function, other xml functions
Have a table of XPath expressions and another table with XML data. Wanting to run a query that evalutes xpath expressions against the xml column via
select xmldata.query(rulesXpath) from xmlDataTable
However an error occurs...
Error:The argument 1 of the xml data type method "query" must be a string literal.
Upvotes: 16<=-=Jul 30 2007 3:49AM=-=>
I get this same problem under different circumstances:
Having to pass in a string literal makes my code a maintenance nightmare because readability is incomprehensible. This means the XQuery capabilities in SQL Server 2005 are pretty much useless, unless you only want one column returned and that isn’t the real world.<=-=Oct 19 2007 3:40PM=-=>
Dear Jeff, thanks for your feedback. This has been one of the major customer request items but due to the required changes in the infrastructure, we are not able to provide it in SQL Server 2008. We will however work on enabling it in a future release as soon as possible.
Current workarounds include using dynamic SQL.
I am closing this entry as a duplicate to the related feature request at http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=168552 and request that future feedback on this topic is done at this other entry.
Thanks and best regards
Anyone knows if this has been fixed in latest SQL editions? Seems like a pain even today!?