Array
(
)

comparar 2 campos com valores separados por |

Marcio Dfdfdfdf
   - 24 jan 2014

tenho a seguinte query
ProcPaginacao @ViewName = 'SELECT DISTINCT
e009.itemid,
e009.categoriaid,
e009.titulo,
e009.resumo,
e009.texto,
e009.arquivos,
convert(char, e009.dtcad, 103) as datahora_cadastro,
convert(char, e009.dtcad, 108) as hora_cadastro,
e008.nome as categoria,
e009.dtcad,
e008.link_icone_categoria,
e001.Nome as nome
FROM e009_conteudos_itens as e009
INNER JOIN e011_conteudos_filtros as e011 ON e011.itemid = e009.itemid
INNER JOIN e008_conteudos_categorias as e008 ON e008.categoriaid = e009.categoriaid
LEFT JOIN e001_pessoas as e001 ON e001.pessoaid = e009.pessoaid
WHERE CAST(FLOOR(CAST(GETDATE() AS FLOAT)) AS DATETIME)
BETWEEN ISNULL(e011.dtinicio, CAST(FLOOR(CAST(e009.dtcad AS FLOAT)) AS DATETIME))
AND ISNULL(e011.dtfim, CAST(FLOOR(CAST(GETDATE() + 1 AS FLOAT)) AS DATETIME)) AND ((e009.perfilid <> 91) or (e009.perfilid is null)) AND (e011.curso is null or (e009.dtcad <= ''2013-08-01 00:00:00.000'') or (e011.curso LIKE ''%|12338|%'') or (e011.curso LIKE ''%|12345|%'') or (e011.curso LIKE ''%|12348|%'') or (e011.curso LIKE ''%|12364|%'') or (e011.curso LIKE ''%|12621|%'') or (e011.curso LIKE ''%|12631|%'') or (e011.curso LIKE ''%|12736|%'') or (e011.curso LIKE ''%|12841|%'') or (e011.curso LIKE ''%|12862|%'') or (e011.curso LIKE ''%|12867|%'') or (e011.curso LIKE ''%|12868|%'') or (e011.curso LIKE ''%|12916|%'') or (e011.curso LIKE ''%|12922|%'') or (e011.curso LIKE ''%|12955|%'') or (e011.curso LIKE ''%|12968|%'') or (e011.curso LIKE ''%|13065|%'') or (e011.curso LIKE ''%|13072|%'') or (e011.curso LIKE ''%|13118|%'') or (e011.curso LIKE ''%|13177|%'') or (e011.curso LIKE ''%|13206|%'') or (e011.curso LIKE ''%|13328|%'') or (e011.curso LIKE ''%|13506|%'') or (e011.curso LIKE ''%|13555|%'') or (e011.curso LIKE ''%|13556|%'') or (e011.curso LIKE ''%|13603|%'') or (e011.curso LIKE ''%|13638|%'') or (e011.curso LIKE ''%|13721|%'') or (e011.curso LIKE ''%|13722|%'') or (e011.curso LIKE ''%|13775|%'') or (e011.curso LIKE ''%|13784|%'') or (e011.curso LIKE ''%|14050|%'') or (e011.curso LIKE ''%|14060|%'') or (e011.curso LIKE ''%|14137|%'') or (e011.curso LIKE ''%|14154|%'') or (e011.curso LIKE ''%|14170|%'') ) AND (e011.turma is null or (e009.dtcad <= ''2013-08-01 00:00:00.000'')
AKI É O PROBLEMA, no OR , POS NESTE CAMPO PODE VIR MAIS DE 1 NUMERO, PODEM VIR VARIOS. O CAMPO TEM VARIOS NUMEROS SEPARADOS POR | .
AGRADEÇO SE PUDEREM ME INDICAR UMA SOLUCAO.
OR (42014) in (1,2,12013,12014,22013,22013,22014,32013,32014,42013,42014,52013,52014,62013,62014,72013,72014,82013,92013,122013,122013,132013,142013,152013,162013,172013,182013,192013,202013,212013,252013,262013,282013,312013,322013,332013,342013,352013,382013,392013,432013,432013,442013,452013,472013,472013,482013,512013,542013,552013,562013,572013,592013,602013,612013,622013,632013,642013,652013,672013,682013,692013,712013,722013,732013,782013,792013,802013,812013,822013,832013,842013,852013,862013,872013) )
AND e009.categoriaid = 27 AND ((e011.polo is null) OR (e011.polo LIKE ''%|4-0-12418|%'')) AND e011.sistemaid = 33', @numeroItens = 20, @ordenacao = 'dtcad DESC'

Jefferson Santos
   - 24 jan 2014

Utilize Cast e converta o campo.

Faabiianooc
   - 27 jan 2014

Verifique as funções charindex e patindex.