Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trigger & identity column
Message
De
08/04/2002 17:41:44
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Titre:
Trigger & identity column
Divers
Thread ID:
00642396
Message ID:
00642396
Vues:
57
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
Fil
Voir

Click here to load this message in the networking platform