select codemp, tipcont, codoferta, datvar3 from RPS.dbo.faoferc (NOLOCK) where codemp in ('003', '016', '018') and len(isnull(datvar3,'')) = 19 and isnull(datvar4,'0') + 0 = 1 and datvar3 >= '20170101' and 'WS_OFERTAS.PHP, codemp(' + codemp + '), tipcont(' + tipcont + '), codoferta(' + codoferta + '), datvar3(' + datvar3 + ')' not in ( select IDWS + ', ' + PARA from GERAPLI.dbo.HA_WS_LOG_ERROR (NOLOCK) where IDWS = 'WS_OFERTAS.PHP' and FECHA_HORA >= '2017/01/01' and PARA = 'codemp(' + codemp + '), tipcont(' + tipcont + '), codoferta(' + codoferta + '), datvar3(' + datvar3 + ')' )