I have a basic query that is returning the unique CharacterID for the the different programs
Select Distinct CharacterId
From dbo.Character c
inner join (select character Id from programa ) on a.characterid = c.characterid
inner join (select character Id from programb ) on b.characterid = c.characterid
inner join (select character Id from programc ) on c.characterid = c.characterid
inner join (select character Id from programd ) on D.characterid = c.characterid
inner join (select character Id from programe ) on e.characterid = c.characterid
inner join (select character Id from programf ) on f.characterid = c.characterid
inner join (select character Id from programg ) on g.characterid = c.characterid
inner join (select character Id from programh ) on h.characterid = c.characterid
The issue is that when I run the query seperately for each program, each runs in less than a second. WHen I run it as above, they block each other and run for 10+ minutes. What is the best way to run the above query so that it runs fast and doesn't block each other.
This is a view above. I tried turning into a SP and using temptables for each inner join but that didn't work either.