4

input:

Declare @OUT xml
select @OUT = N'
<row>
 <kind>MainCat</kind>
 <sortid>1</sortid>
 <kind_id>1</kind_id>
 <PPoet>حافظ</PPoet>
 <MTitle>حافظ</MTitle>
 <Row>1</Row>
</row>'
select T.X.value('@Kind', 'nvarchar(50)') as kind,
T.X.value('@sortid', 'int') as sortid
from @out.nodes('/row') as T(X)
this select return NULL!
asked Dec 13, 2012 at 17:02

1 Answer 1

4

Very close:

select 
 T.X.value('./kind[1]', 'nvarchar(50)') as kind,
 T.X.value('./sortid[1]', 'int') as sortid
from @out.nodes('/row') as T(X);
answered Dec 13, 2012 at 17:22
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.