Saturday, September 28, 2013

TSQL For foreign key and Primary key

Hi


PFB code,




select 1 Id,10 ArmourId, 11 ShieldId into #temp1 union all
select 2,12,11 union all
select 3,12,13


select 10 Id,'A1' MaterialName, 'True' IsArmour into #temp2 union all
select 11,'S1','False' union all
select 12,'A2','True' union all
select 13,'S2','False'

select a.id,b.materialname ArmourName,c.materialname ShieldName from #temp1 a
inner join #temp2 b on a.armourid = b.id
inner join #temp2 c on a.shieldId = c.id

Thanks


Saravana Kumar C


No comments:

Post a Comment