Ver Mensaje Individual
  #1 (permalink)  
Antiguo 16/09/2005, 02:33
kakarot
 
Fecha de Ingreso: diciembre-2003
Mensajes: 288
Antigüedad: 20 años, 4 meses
Puntos: 0
trigger de insertar

Buenas he hecho un trigger para insertar el identificador de una tabla en otra, no me da error pero el identificador cuando lo inserta en la otra tabla me lo pone como 0, y no lo entiendo ya que le paso como valor el @id

CREATE TRIGGER incrementar4 ON dbo.IRIS_ECS
AFTER INSERT
AS
begin
Declare @id int
select @id=ID_EC from inserted
update IRIS_ECS SET ID_EC=dbo.IdECS() WHERE ID_EC=@id
insert IRIS_COMUNICACIONES Values (@id,0,0,0,0,0,0,300,0,0)
end

Otra posibilidad q habia penado pero no me acaba de convencer es:


CREATE TRIGGER incrementar4 ON dbo.IRIS_ECS
AFTER INSERT
AS
begin
Declare @id int
select @id=ID_EC from inserted
update IRIS_ECS SET ID_EC=dbo.IdECS() WHERE ID_EC=@id
insert IRIS_COMUNICACIONES Values (0,0,0,0,0,0,0,300,0,0)
update IRIS_COMUNICACIONES SET ID_EC=@id WHERE ID_EC=0
end

GRACIAS

Última edición por kakarot; 16/09/2005 a las 04:44