Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Ranjit.ileni
Posting Yak Master
183 Posts |
Posted - 2011-08-26 : 05:32:20
|
| [code]create table #BaseTable( Id int identity ,Metadata Varchar(100))insert into #BaseTableselect 'tiffin' union allselect 'lunch' union allselect 'snacks' union allselect 'dinner' union allselect 'Tea' create table #temp( Id int identity ,Rid int ,Metadata Varchar(100) ,PaxCount int ,comment varchar(100))insert into #tempselect 10,'tiffin',1,'needed' union allselect 10,'lunch',2,'not needed' union allselect 10,'snacks',35,'not interested' union allselect 10,'dinner',5,'ok' union all select 11,'dinner',4,'ok' select * from #BaseTableselect * from #tempHere #BaseTable have metadata values ,we can enter multiple rows for metadataand #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[/code]Rid tiffin comment lunch comment snacks comment dinner comment Tea comment10 1 needed 2 not needed 35 not interested 5--Ranjit |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|
|
|