SQL Server - Excluding inner join table from the query

Asked By Abhi Rana on 17-Jul-13 07:35 AM

I have require to reduce the overhead of the query given below, here I need to replace one of the inner join in the below query

like i need to replace tableB with some temp table and datatable is not part of this query.

Options

  1. Create tempTableB with limited records as need by main query and apply inner join to temp table after getting resultant from main query (excluding tableB inner join )

  2. Create datatable of table B and datatable of main query (excluding tableB inner join ) and use select() or linq to get filter data.

PLEASE suggest best option for this.

Query

select * from tblMain as main inner join tableA as hf on ((hf.eid =100) and (hf.parentlevel =1) and (hf.childid =session.hid1 )) inner join tableB as h on ((h.eid =100) and (h.id =hf.parentid )) inner join tableC as ld on ((ld.eid =100) and (ld.labelid =h.labelid ) and (ld.langid =1)) inner join tableD as btsl on ((btsl.sid =main.sid )