Information générale
Forum:
Microsoft SQL Server
Titre:
Trigger & identity column
Hi,
I am having an identity problem in the inserted table
(the one whit the trigger).
When i include the 2 INSERT INTO statements, in my
trigger, my identity column in my table dosen't get
updated immediately. And when i take them away it works
fine.
Let say i open my table in the Enteprise Manager and
add a row. When i change row to add my new row and
fire my trigger my identity column dosen't get updated
i have to manuelly call a refresh. It give me the same
problem when i add a row whit Visual Basic, SQL Server
dosen't give me back the new identity.
Why?
I have included my trigger.
CREATE TRIGGER tg_ProEnt_Insert ON [dbo].[Pro_Ent]
AFTER INSERT
AS
BEGIN
DECLARE @intPro_NRI INTEGER;
DECLARE @intEnt_NRI INTEGER;
IF @@ROWCOUNT = 0 RETURN
SELECT @intPro_NRI = Pro_NRI,
@intEnt_NRI = Ent_NRI
FROM INSERTED
INSERT INTO InvProEnt (IPE_Bris, Pro_NRI, Ent_NRI)
VALUES (0, @intPro_NRI, @intEnt_NRI)
INSERT INTO InvProEnt (IPE_Bris, Pro_NRI, Ent_NRI)
VALUES (1, @intPro_NRI, @intEnt_NRI)
END
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement