I have a family table and would like to group all related members under the same familyID. This is a replication of existing business data, 14,000 rows. The familyID can be randomly assigned to any group, its sole purpose is to group the names:
declare @tv table (member varchar(255), relatedTo varchar(255))
insert into @tv
select 'John', 'Mary'union all
select 'Mary', 'Jessica' union all
select 'Peter', 'Albert' union all
select 'Peter', 'Nancy' union all
select 'Abby', null union all
select 'Jessica', 'Fred' union all
select 'Joe', 'Frank'
I would like my result to look like this:
Thanks a lot!!