trigger on insert to insert

  • I am trying to create a trigger which on insert, inserts a couple of the columns thave been inserted into a different table.. but i don't know the correct syntax and cant seem to find anything but the below format on good old google..

    CREATE TRIGGER Trig_NewServer

    ON [dbo].[tbl_ServerLocation]

    after INSERT

    as

    begin

    insert into [dbo].[tbl_ConnectionStrings] ([connection string], [function])

    select [connection string], [function] from inserted

    GO

    Whats the easiest way to achieve this?

  • That code looks syntatically correct. Can't tell any more without more details. What's the problem with that trigger?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • just realised after pasting the error

    Msg 102, Level 15, State 1, Procedure Trig_NewServer, Line 7

    Incorrect syntax near 'inserted'.

    I was missing END after inserted.. what a fool! (me of course)

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

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