select * from ( select oh_client CLIENT, ot_oh_idnr OBJ_ID, ot_Content PRCS_LINE, ltrim(replace(ot_content, ':INC ','')) include_STR, charindex(' ',ltrim(replace(ot_content, ':INC ','')),0) include_LEN, rtrim(replace( substring(ltrim(replace(ot_content, ':INC ','')), 0, charindex(' ',ltrim(replace(ot_content, ':INC ','')),0)) ,',','')) include_FILE, case charindex(' ',ltrim(replace(ot_content, ':INC ','')),0) when 0 then ltrim(replace(ot_content, ':INC ','')) else rtrim(replace( substring(ltrim(replace(ot_content, ':INC ','')), 0, charindex(' ',ltrim(replace(ot_content, ':INC ','')),0)) ,',','')) end inc_file from OT, OH where 1=1 and oh_idnr = ot_oh_idnr and OH_Client = 100 and ot_content like ':INC %' ) TABLE_INCLUDE where 1=1 and inc_File not in (select oh_name from oh where oh_client = 100)