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 xivalue('local-name(.)','nvarchar(MAX)') as colname why 'local-name(.)' what is local-name (.) what does it mean. again xivalue('.','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.
xivalue('.','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
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.