marcar registros para comparação - SQL
18/01/2018
0
Caros,
Preciso pegar uma quantidade de X de registros do Banco e mandar para enriquecimento, porem não estou sabendo como demarcar esses registros no banco em um campo ''''regra_enriquecida'''', ou inserir esses cpf em uma tabela, pois estou utilizando o TOP 40000, que é a quantidade de registros que preciso.
fiz o seguinte comando:
update BD_TOKIO_MARINE_UNIFICADO..tb
set REGRA_ENRIQUECIDA = ''''P20180118''''
where INDICE in (
select top 40000 * from BD_TOKIO_MARINE_UNIFICADO..tb tb with (nolock) inner join BD_TOKIO_MARINE_UNIFICADO..C1_TOKIO_MARINE_UNIFICADO c1 with (nolock)
on tb.INDICE = c1.INDICE
where QUEUE_ID in (5221,5222,5233)
and status in (26,27,28,31,89,89,90,91,98,99,101)
and MUNICIPIO not in (''''FORTALEZA'''')
)
porem ele me reposta essa msg de erro
"Only one expression can be specified in the select list when the subquery is not introduced with EXISTS."
Preciso pegar uma quantidade de X de registros do Banco e mandar para enriquecimento, porem não estou sabendo como demarcar esses registros no banco em um campo ''''regra_enriquecida'''', ou inserir esses cpf em uma tabela, pois estou utilizando o TOP 40000, que é a quantidade de registros que preciso.
fiz o seguinte comando:
update BD_TOKIO_MARINE_UNIFICADO..tb
set REGRA_ENRIQUECIDA = ''''P20180118''''
where INDICE in (
select top 40000 * from BD_TOKIO_MARINE_UNIFICADO..tb tb with (nolock) inner join BD_TOKIO_MARINE_UNIFICADO..C1_TOKIO_MARINE_UNIFICADO c1 with (nolock)
on tb.INDICE = c1.INDICE
where QUEUE_ID in (5221,5222,5233)
and status in (26,27,28,31,89,89,90,91,98,99,101)
and MUNICIPIO not in (''''FORTALEZA'''')
)
porem ele me reposta essa msg de erro
"Only one expression can be specified in the select list when the subquery is not introduced with EXISTS."
Pâmela Souza
Curtir tópico
+ 0
Responder
Posts
19/01/2018
Felipe Souza
Olá, Teste retirar o * (asterisco) e colocar a coluna na subquery como abaixo:
update BD_TOKIO_MARINE_UNIFICADO..tb
set REGRA_ENRIQUECIDA = ''''P20180118''''
where INDICE in (
select top 40000 INDICE from BD_TOKIO_MARINE_UNIFICADO..tb tb with (nolock) inner join BD_TOKIO_MARINE_UNIFICADO..C1_TOKIO_MARINE_UNIFICADO c1 with (nolock)
on tb.INDICE = c1.INDICE
where QUEUE_ID in (5221,5222,5233)
and status in (26,27,28,31,89,89,90,91,98,99,101)
and MUNICIPIO not in (''''FORTALEZA'''')
)
update BD_TOKIO_MARINE_UNIFICADO..tb
set REGRA_ENRIQUECIDA = ''''P20180118''''
where INDICE in (
select top 40000 INDICE from BD_TOKIO_MARINE_UNIFICADO..tb tb with (nolock) inner join BD_TOKIO_MARINE_UNIFICADO..C1_TOKIO_MARINE_UNIFICADO c1 with (nolock)
on tb.INDICE = c1.INDICE
where QUEUE_ID in (5221,5222,5233)
and status in (26,27,28,31,89,89,90,91,98,99,101)
and MUNICIPIO not in (''''FORTALEZA'''')
)
Responder
Clique aqui para fazer login e interagir na Comunidade :)