the code above works, but I want to use parameter to substitue string
literal '/root/experience', like this
declare @query as nvarchar(200)
set @query = N'/root/experience'
select experience.query(@query)
from UsersProperties
SqlServer gave me an error:
Msg 8172, Level 16, State 1, Line 4
The argument 1 of the xml data type method "query" must be a string literal.
So is there any other approach?
Not really. What you can do is e.g.
declare @n nvarchar(20)
set @n = N'experience'
select experience.query(N'/root/*[local-name() = sql:variable("@n")]')
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/