you can change SELECT @pubID,(SELECT entity_item_id from #TMPTABLE WHERE acc_no = '608' AND entity_id = @progID),(SELECT entity_item_id from #TMPTABLE WHERE acc_no = '11606' AND entity_id = @orgID),GETDATE(),@userId,@relSupp,1,'Fuel cooled oil cooler'
toselect @pubID, max(case when acc_no = '608' then entity_item_id end), max(case when acc_no = '11606' then entity_item_id end), GETDATE(), @userId, @relSupp, 1, 'Fuel cooled oil cooler'from #TMPTABLEwhere acc_no in ('608', '11606')and entity_id = @progID
does all your union query basically the same ? only the acc_no = 'xxx' part that varies ?
KH[spoiler]Time is always against us[/spoiler]