Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2007
    Location
    West Midlands
    Posts
    16

    Unanswered: Trigger update command

    Hi
    I've created this simple trigger that will insert records into another table when an insert has occurred on another.

    table A
    table B


    CREATE TRIGGER [TG_MYTRIGGER]
    ON [dbo].[A]
    AFTER INSERT
    AS
    Begin
    INSERT B (date, id)
    Select DISTINCT i.date,i.id
    from inserted i
    End




    What i cant figure out is how to insert the date plus one month into table B

    so instead of just inserting into the second table the i.date i want the i.date + one month.

    Does anyone know how this could be done.

    many thanks

    Bil

  2. #2
    Join Date
    Jan 2007
    Location
    California, USA
    Posts
    520
    look at DATEADD in BOL. That will explain it completly.

    Breifly, the syntax is: DATEADD(datepart, number, date)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •