Identity and trigger - wonder problem

Identity and trigger - wonder problem

Post by Mark » Fri, 02 Jun 2000 04:00:00



Hi,
here is script for two tables and one trigger.
If I insert rows into table A, new rows are writen into
table B by triger.
It is right. But if is writen new row into B manualy, then
when I insert
row into A, I cannot see new value in ID column without
refresh.
Is is because identity column in A and B are different.
After all I need unique column in table B for other
references.
Please, help me! Thanks.

CREATE TABLE [dbo].[A] (
        [ID] [int] IDENTITY (1, 1) NOT NULL ,
        [Col] [char] (10) NOT NULL
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[B] (
        [ID] [int] IDENTITY (1, 1) NOT NULL ,
        [Col] [char] (10) NOT NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[A] WITH NOCHECK ADD
        CONSTRAINT [PK_A] PRIMARY KEY  CLUSTERED
        (
                [ID]
        )  ON [PRIMARY]
GO

SET QUOTED_IDENTIFIER  ON    SET ANSI_NULLS  ON
GO

CREATE TRIGGER A_Trigger ON dbo.A
FOR INSERT
AS

INSERT INTO B (Col) VALUES ('xxx')

GO
SET QUOTED_IDENTIFIER  OFF    SET ANSI_NULLS  ON
GO

* Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping.  Smart is Beautiful

 
 
 

1. Trigger problem w/ @@Identity...Please Help!!

O.k., working on Access 2000 ADP <-> SQL Server 7.0:
I have a form which is bound to a view..the underlying table (T1) in
the view has a trigger which inserts data into another table (T2)
based on the inserted values..

instead of recieving the correct identity for T1 it actually recieves
the new identity for T2 and applies it to the form as the T1 record
identity. now if i go back and change any data on the T1 record, the
resync command goes and an error pops up becuase of the invalid
identity value.
if anyone understands this or has run into it please help...
thanks,
jon

2. I/O bad request....

3. Problem with @@identity and trigger

4. Ingres Checkpoints directly to tape

5. Trigger and @@IDENTITY problems

6. FPW2.6 browse problem

7. problem with @@identity and trigger

8. UPDATE SQL script

9. Trigger (insert) and @@identity problem...

10. IDENTITY column problems with triggers

11. Passing identity values outside triggers

12. help! @@IDENTITY and nested triggers