select top 30000 * from tbl_CHO_Operators cho where cho.cho_type in ( 'U', 'I' ) and nullif( cho.cho_hostLocation, 0 ) is null and not exists ( select hm.queueId from tbl_1FS_HostMapping hm where hm.choId = cho.cho_id and nullif( hm.linkId, 0 ) is null ) insert into tbl_1FS_HostMapping ( queueDate, choId, linkLevel ) values ( , , ) insert into tbl_1FS_HostMapping ( queueDate, choId, linkLevel ) values ( , , )