select #attributes.selectedColumns# from tbl_OFS_Bids b with (nolock) left outer join tbl_OFS_BidLines bl with (nolock) on b.bidId = bl.bidId and b.ownerId = bl.ownerId and b.ownerType = bl.ownerType left outer join tbl_OFS_BidLineProducts blp with (nolock) on bl.bidLineId = blp.bidLineId and bl.ownerId = blp.ownerId and bl.ownerType = blp.ownerType left outer join tbl_CDR_Distributors c with (nolock) on blp.awardedDstId = c.cdr_recordId and blp.ownerId = c.ownerId and blp.ownerType = c.fsl_tablecode left outer join tbl_PRD_Skus s with (nolock) on blp.bidSkuId = s.skuId left outer join tbl_PRD_Products p with (nolock) on s.prodId = p.prodId and s.fsl_tablecode = p.fsl_tablecode and s.ownerId = p.ownerId left outer join tblManufacturers mfr with (nolock) on s.mfrId = mfr.mfr_id where b.ownerid = and b.ownerType = and b.bidId = and coalesce( b.archived, 'N' ) = 'N' and bl.bidLineId = and blp.bidSkuId = and blp.bidSkuId not in ( ) and blp.bidLineProductId = and p.shortDesc = and mfr.mfr_id = and blp.awardedDstId = and ( bl.bidLineNumber like or bl.bidLineDescription like ) order by #attributes.orderBy#