delete table

  • Query to delete, all the records from a table before half an hour,…

    Delete * from table where condition=100 and …..what we have write here…for time…

    Regards,

  • no you can not do such a thing... you should save the script for deleting also with parameter that identify the condition and after that you will do schedule the job to do it for example after 30 min!

    ============================================================
    SELECT YOUR PROBLEM FROM SSC.com WHERE PROBLEM DESCRIPTION =
    http://www.sqlservercentral.com/articles/Best+Practices/61537/[/url]

  • Do you have a DATETIME column on the table? You would need it to delete rows older than 30 minutes. To do that you can use the DATEADD function in your where clause.

    DELETE FROM dbo.YourTable WHERE Condition=100 AND YourTimeColumn < DATEADD(MINUTE, -30, GETDATE())

  • kumar99ms (8/20/2008)


    Query to delete, all the records from a table before half an hour,…

    Delete * from table where condition=100 and …..what we have write here…for time…

    Regards,

    I am afraid your question is not clear. What do you want? You want to delete all the records older than 30 mins or you want the delete statement should be fired after 30 mins?

  • Ok the ideas are here and if you want to clearly solution you must post the table definition and some sample data just to do the things correct!

    ============================================================
    SELECT YOUR PROBLEM FROM SSC.com WHERE PROBLEM DESCRIPTION =
    http://www.sqlservercentral.com/articles/Best+Practices/61537/[/url]

  • hi every body

    Thanks u for your effor

    I want a query for delete every half an hour.

    my condition is i am not schedule an job for this i am not use any Truncate also

    Could plz any query using sysdate time or datetime for this plz help me

  • you can not do this using SQL. You will have to either schedule a job to do this or create a Windows Service which will fire the delete query every half-an-hour

  • Another option would be to do the delete on an insert trigger, it would add additional overhead on the table, but if the table does not have too much activity then it should be fine. So the table with the trigger would constantly maintain itself. On the one hand it creates additional overhead, but the deletes will be done over smaller data sets because it may be executed more frequently, so it may even out.

    You would still need a column that has the creation time of each record.

  • Johannes Fourie (8/20/2008)


    Another option would be to do the delete on an insert trigger, it would add additional overhead on the table, but if the table does not have too much activity then it should be fine. So the table with the trigger would constantly maintain itself. On the one hand it creates additional overhead, but the deletes will be done over smaller data sets because it may be executed more frequently, so it may even out.

    You would still need a column that has the creation time of each record.

    Hey Johannes

    This fella wants to remove all the data from after every thirty minute. After every thirty minute, a query should execute and remove all the data from the table.

Viewing 9 posts - 1 through 8 (of 8 total)

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