select so.* from tbl_BID_SkusOverride so inner join tbl_BID_Manufacturers bm on so.bidMfrId = bm.bidMfrId inner join tbl_BRO_Principals ppl on ppl.ownerId = bm.ownerId and ppl.ownerType = bm.ownerType and ppl.mfrId = bm.mfrId and ppl.principalId in ( select pt.principalId from tbl_BRO_PrincipalTerritories pt inner join tbl_BRO_PrincipalTerritoryResources ptr on ptr.principalTerritoryId = pt.principalTerritoryId where ptr.resourceType = 'TER' and ptr.resourceId = so.territoryId and pt.hireStatus <> 'I' ) where so.ownerId = and so.ownerType = and so.territoryId = and isnull( so.bidCommentsOverride, '' ) <> '' select bm.bidMfrId from tbl_BID_Manufacturers bm inner join tbl_BRO_Principals ppl on ppl.ownerId = bm.ownerId and ppl.ownerType = bm.ownerType and ppl.mfrId = bm.mfrId and ppl.principalId in ( select pt.principalId from tbl_BRO_PrincipalTerritories pt inner join tbl_BRO_PrincipalTerritoryResources ptr on ptr.principalTerritoryId = pt.principalTerritoryId where ptr.resourceType = 'TER' and ptr.resourceId = and pt.hireStatus <> 'I' ) where bm.ownerId = and bm.ownerType = and bm.bidMfrId = select * from tbl_BID_SkusOverride where ownerId = and ownerType = and territoryId = and bidMfrId = and bidSkuId = update tbl_BID_SkusOverride set bidCommentsOverride = , includeCommentsOnQuoteOverride = 'Y' where overrideId = insert into tbl_BID_SkusOverride ( ownerId, ownerType, bidSkuId, bidMfrId, territoryId, bidCommentsOverride, includeCommentsOnQuoteOverride, createdDate ) values ( , , , , , , 'Y', #Now()# )