marcar registros para comparação - SQL

Banco de Dados

18/01/2018

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."
Pâmela Souza

Pâmela Souza

Curtidas 0

Respostas

Felipe Souza

Felipe Souza

18/01/2018

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'''')
)
GOSTEI 0
Pâmela Souza

Pâmela Souza

18/01/2018

Muito obrigada,
GOSTEI 0
POSTAR