Select Query on xml data



I have;



declare @result xml
set @result='<root><data><color20>red</color20></data></root>'

select tab.col('@color20','varchar(500)'
from @result.nodes(/data)tab(col)


I want to bring 20 from variable called @period



select tab.col('@color+'+@period+'','varchar(500)'
from @result.nodes(/data)tab(col)


when i run above query i am getting below error The argument 1 of the XML data type method "value" must be a string literal.


How can I do that?


No comments:

Post a Comment