TRIGGER on INSERT INTO SELECT FROM + add 1 row on INSERT

  • hi need help how to do this

    TRIGGER on INSERT INTO SELECT FROM table + add one row for evry employee (on insert)

    this is table tb_test1

    empid fname unit fld1 fld2 fld3 fld4 fld5

    ----------------------------------------------------------------------------------------

    111 aaa 1 a b c d d

    222 bbb 3 a c e g g

    333 cccc 5 s h t u j

    INSERT INTO [nili].[dbo].[tb_test2]

    ([empid]

    ,[fname]

    ,[unit]

    ,[fld1]

    ,[fld2]

    ,[fld4]

    ,[fld5])

    SELECT [empid]

    ,[fname]

    ,[unit]

    ,[fld1]

    ,[fld2]

    ,[fld4]

    ,[fld5]

    FROM [nili].[dbo].[tb_test1]

    i need to insert into tb_test2 + add TRIGGER

    ADD one row for evry employee

    val_orginal=1 (the orginal ROW)

    val_orginal=2 (the extra ROW)

    this is table tb_test2

    after the insert

    HOW TO THIS

    empid fname unit fld1 fld2 fld3 fld4 fld5 val_orginal

    -------------------------------------------------------------------------------------------------

    111 aaa 1 a b c d d 1

    111 aaa 1 - - - - - 2

    222 bbb 3 a c e g g 1

    222 bbb 3 - - - - - 2

    333 cccc 5 s h t u j 1

    333 cccc 5 - - - - - 2

    and tnx for the help

  • Make sure recursive triggers is off, sp_dboption 'recursive triggers' and in a trigger on table2 do:

    Insert Into table2

    Select

    column_list

    From

    inserted

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

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