Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2003
    Location
    The Netherlands
    Posts
    9

    Unanswered: Trigger, delete row after it's 20 days old

    hi all,

    i have a table e.g. product. it has a product_id and certain other values. One of them is date, which default value is: getDate().

    The product has to be deleted after 20 days. I thought it is doable with a trigger...is it? And (hopefully) how?

    thnx, greetz
    Erik

  2. #2
    Join Date
    Sep 2003
    Posts
    69
    Syntax for a trigger from EM:

    Code:
    CREATE TRIGGER [TRIGGER NAME] ON [table] 
    FOR INSERT, UPDATE, DELETE 
    AS
    So you probably can't have it run randomly... Maybe you should have it
    run when you insert or update? Otherwise you could just have a stored procedure to do it and login once and a while and run it... Or write a program to run it daily for you... IE a little VB program on the server that every day it connects and executes
    Code:
    "EXECUTE oldProductCleanRemoval"
    or something like that

  3. #3
    Join Date
    Jan 2003
    Location
    India
    Posts
    523
    it can be done by a trigger but it doen't make any sense to me,i would go for a stored procedure and schedule it to run every day.

  4. #4
    Join Date
    Sep 2003
    Location
    The Netherlands
    Posts
    9
    Nice one too! Will remember it for monday

    Thnx for the replies

Posting Permissions

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