I have xml in following format
<Entity>
<name>John</name>
<aliases><alias>Johnny</alias></aliases>
<aliases><alias>Johnson</alias></aliases>
</Entity>
<Entity>
<name>Smith</name>
<aliases><alias>Smithy</alias></aliases>
<aliases><alias>Schmit</alias></aliases>
</Entity>
I want to insert them in table so the table should have 4 records in the example.
columns are name and alias.
name | alias
John | Johnny
John | Johnson
Smith| Smithy
Smith| Schmit
How can I achive this using cursor or something else?
What i have tried. In cursor for entity i try insert alias value,but only first alias is taken.
insert into TESTTABLE
(EntityID,Alias)
select
@EntityID as EntityID,
Alias
from OpenXml(@ixml, '/Aliases',2)
with (
Alias varchar(255) '.'
)