XQUERY SQL - How to pass individual node element(s) as variables?
Is there an alternate way to pass node elements dynamically than the one shown below - ?
select XMLTable.XMLCOL.query('//*[local-name()=sql:variable("@node")')
For e.g., even if I am trying to give the fully qualified path, I do not want to hard code the node elements, instead I would like to pass them individually as parameters.
Under the section -
Example: Query Using sp_开发者_Go百科executesql
@ http://msdn.microsoft.com/en-us/library/ms345118(v=sql.90).aspx
it says -
query contains wildcards (*) and node tests using node names and is hard to optimize well. Consequently, it performs much worse than the original query and the query construction approach.
May be like this:
declare @qry nvarchar(1000)
set @qry = 'select XMLCOL.query(''//' + @node + ''') from XMLTable'
exec( @qry )
精彩评论