pls suggest me with why it is so

  • if suppose i am having a before Insert Trigger and a constraint on the same table then which will fire first and why .

    thanx.

  • Can't really explain why except that it makes more sens that way... but see for yourself :

    CREATE TABLE MyTest(

    Atest varchar(50) not null,

    constraint ck_test_ATest check (ATest = '1')

    )

    GO

    CREATE TRIGGER [trMyTest_IO_Insert] ON [dbo].[MyTest]

    INSTEAD OF INSERT

    AS

    raiserror ('trMyTest_IO_Insert', 13, 1)

    GO

    Insert into MyTest (ATest) values ('This fails the check constraint')

    --FAILS on the instead of insert trigger

    GO

    drop table MyTest

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply