create table #BaseTable
(
Id int identity
,Metadata Varchar(100)
)
insert into #BaseTable
select 'tiffin' union all
select 'lunch' union all
select 'snacks' union all
select 'dinner' union all
select 'Tea'
create table #temp
(
Id int identity
,Rid int
,Metadata Varchar(100)
,PaxCount int
,comment varchar(100)
)
insert into #temp
select 10,'tiffin',1,'needed' union all
select 10,'lunch',2,'not needed' union all
select 10,'snacks',35,'not interested' union all
select 10,'dinner',5,'ok' union all
select 11,'dinner',4,'ok'
select * from #BaseTable
select * from #temp
Here #BaseTable have metadata values ,we can enter multiple rows for metadata
and #temp Table uses the metadata as a foreignkey ref.
expected output:
columns names should be dynamic:
Rid tiffin comment lunch comment snacks comment dinner comment Tea comment
Rid tiffin comment lunch comment snacks comment dinner comment Tea comment
10 1 needed 2 not needed 35 not interested 5
--Ranjit