PARA OS FERAS - CONCATENAR VALORES
31/03/2003
0
SELECT CAMPO1||CAMPO2 FROM TABELA
SE O CAMPO1 ESTIVER NULO O RESULTADO SERÁ NULO.
COMO FAZER PARA RETORNA O VALOR DO CAMPO2 ???
SE O CAMPO1 ESTIVER NULO O RESULTADO SERÁ NULO.
COMO FAZER PARA RETORNA O VALOR DO CAMPO2 ???
Anonymous
Curtir tópico
+ 0
Responder
Posts
31/03/2003
Anonymous
SELECT CAMPO1||CAMPO2 FROM TABELA
SE O CAMPO1 ESTIVER NULO O RESULTADO SERÁ NULO.
COMO FAZER PARA RETORNA O VALOR DO CAMPO2 ???
Vc já tentou algo com union?? Veja:
select campo1 || campo2 from tabela
where (not campo1 is null)
union
select CAST(campo2 as VARCHAR( TAM_CAMPO1 + TAM_CAMPO 2) from tabela
where (campo1 is null)
onde TAM_CAMPO1 e TAM_CAMPO2 tamanho dos campos 1 e 2 respec.
Isso deve funcionar, mas com certeza nao é coisa muito agradável. Sugiro dar uma olhada em UDFs.
Responder
Clique aqui para fazer login e interagir na Comunidade :)