开发者

XQUERY SQL - How to pass individual node element(s) as variables?

开发者 https://www.devze.com 2023-03-27 09:47 出处:网络
Is there an alternate way to pass node elements dynamically than the one shown below - ? select XMLTable.XMLCOL.query(\'//*[local-name()=sql:variable("@node")\')

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 )
0

精彩评论

暂无评论...
验证码 换一张
取 消