Try this:
select child,father as [name],'father' as relation from table
union
select child,mother as [name],'mother' as relation from table
order by child,parent
I would include ALL on the UNION to prevent SQL Server from sorting and eliminating duplicates. Also, Order By Name rather than Parent or use Parent as the column name in the query as I have done below.
Select Child, father as Parent, 'Father' as Relation
from table
Union All
Select Child, mother, 'Mother' as Relation
From table
Order By child, parent Terry L. Broadbent - DBA
Computing Links:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.