I have below xml present as a column(Name UserBody) value of the table called tblUsers.
I have to read NewUserType name i.e. "SampleUserName" using Xpath in SQL.
<UserTypeAdded xmlns="http://schemas.datacontract.org/2004/07/ABC.Domain.Contract.EventModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<UserTypeTypeDetails xmlns:a="http://schemas.datacontract.org/2004/07/ABC.Common.Contract">
<a:Id>550d9a76-3d7d-49f6-9243-f0473d32b123</a:Id>
<a:Name>Special User Types</a:Name>
</UserTypeTypeDetails>
<NewUserType xmlns:a="http://schemas.datacontract.org/2004/07/ABC.Domain.Contract.Base">
<Id xmlns="http://schemas.datacontract.org/2004/07/ABC.Common.Contract">dfa090ff-9756-42fd-be9b-02ac8c6b123</Id>
<Name xmlns="http://schemas.datacontract.org/2004/07/ABC.Common.Contract">SampleUserName</Name>
</NewUserType>
</UserTypeAdded>
I tried using below statement
SELECT
[UserBody].value('(/UserTypeAdded/NewUserType/Name[1])', 'nvarchar(max)') as UserName
FROM tblUsers
but No luck