can any one tell me how Local.name(.) xquery function works. regarding sql construction problem i post a question in a forum and they give me answer. where Local.name(.) xquery function is used but syntax is not clear to me very well.
;with cte as
(
select x.i.value('local-name(.)','nvarchar(MAX)') as colname
,x.i.value('.','nvarchar(max)') as data
from @x.nodes('/Record/DELETED/*') as x(i))
what is the meaning of this line x.i.value(‘local-name(.)’,’nvarchar(MAX)’) as colname why ‘local-name(.)’ what is local-name (.) what does it mean. again x.i.value(‘.’,’nvarchar(max)’) as data please explain the two line in detail. i am not advance user. thanks a lot.
please guide me. thanks
local-name(.)will give you the node name of the current node. If you used local-name(..) you would get the node name of the parent node.x.i.value('.','nvarchar(max)')will give you the content of the the current node.@x.nodes('/Record/DELETED/*')gives you all nodes in/Record/Deleted.So your query will give you a name/value list of all nodes in
/Record/Deleted.