Ver Mensaje Individual
  #2  
Antiguo 07-03-2022
Avatar de Casimiro Noteví
Casimiro Noteví Casimiro Noteví is offline
Merodeador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.682
Reputación: 10
Casimiro Noteví Tiene un aura espectacularCasimiro Noteví Tiene un aura espectacular
Algo así:
Código SQL [-]
begin tran    
  update table with (serializable) set ...    where key = @key     
  if @@rowcount = 0    
  begin      
    insert into table (key, ...) values (@key,..)    
  end 
commit tran

También puedes hacer un insert en un try except y si falla entonces hacer el update

Código Delphi [-]
try
  insert ...
except
  update ...
end
Responder Con Cita