Ir para conteúdo
Fórum Script Brasil
  • 0

Eliminar Dados repetidos usando CURSOR


Marcelo Cavalcanti

Pergunta

COMO USAR O CURSOR COM ESSE SCRIPT????

PARA ELIMINAR OS DADOS REPETIDOS????

SE alguém PODER ME AJUDAR!!!!

declare @manter int;

declare @eliminar int;

set @manter = 80591;

set @eliminar = 202828;

---

update vendas_pagDinheiro

set clienteKey = @manter

where clienteKey = @eliminar;

update vendas_pagCheque

set clienteKey = @manter

where clienteKey = @eliminar;

update vendas_pagCartao

set clienteKey = @manter

where clienteKey = @eliminar;

update vendas_pagFuncionario

set pessoaKey = @manter

where pessoaKey = @eliminar;

update vendas_pagOutros

set pessoaKey = @manter

where pessoaKey = @eliminar;

update vendas.boletos

set clienteKey = @manter

where clienteKey = @eliminar;

update vendas_orcamento

set clienteKey = @manter

where clienteKey = @eliminar;

update vendas_orcamento

set vendedorKey = @manter

where vendedorKey = @eliminar;

delete from clientes.lojasLiberadas

where clienteKey = @eliminar

delete from pessoa.funcionario

where pessoaKey = @eliminar;

delete from pessoa.biometria

where pessoaKey = @eliminar

delete from tbendereco

where pessoaKey = @eliminar;

delete from tbTelefone

where pessoaKey = @eliminar;

delete from cliente_dados

where clienteKey = @eliminar; :wacko:

Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

  • 0

Boa tarde Marcelo,

Prefira utilizar um loop normal. O cursor gasta mais... rs.

Segue um exemplo utilizando um WHILE.

declare @manter int;
declare @eliminar int;

set @manter = 80591;
set @eliminar = 202828;

---
WHILE -- Aqui você colocar a cláusula. Pode-se criar uma variavel de controle.
BEGIN
update vendas_pagDinheiro
set clienteKey = @manter
where clienteKey = @eliminar;
update vendas_pagCheque
set clienteKey = @manter
where clienteKey = @eliminar;

update vendas_pagCartao
set clienteKey = @manter
where clienteKey = @eliminar;

update vendas_pagFuncionario
set pessoaKey = @manter
where pessoaKey = @eliminar;

update vendas_pagOutros
set pessoaKey = @manter
where pessoaKey = @eliminar;

update vendas.boletos
set clienteKey = @manter
where clienteKey = @eliminar;


update vendas_orcamento
set clienteKey = @manter
where clienteKey = @eliminar;

update vendas_orcamento
set vendedorKey = @manter
where vendedorKey = @eliminar;

delete from clientes.lojasLiberadas
where clienteKey = @eliminar

delete from pessoa.funcionario
where pessoaKey = @eliminar;

delete from pessoa.biometria
where pessoaKey = @eliminar

delete from tbendereco
where pessoaKey = @eliminar;

delete from tbTelefone
where pessoaKey = @eliminar;

delete from cliente_dados
where clienteKey = @eliminar;

-- Aqui você incrementa o controle.

END

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...