Auto Row Delete

  • Hello Everybody

    I want to auto delete rows from order table

    My Order Table is Follows:

    OrderID (int), OrderDate(smalldatetime), Status(bit)

    default value of Status is 0

    What I want to do is:

    After insert data into order table, if status is 0 for 20 minutes then row should be delete. Table will auto check that row.

    For Example:

    OrderID = 101

    OrderDate = 22/02/09 14:58:00

    Status = 0

    after 20 minutes = 22/02/09 15:18:00 if status is 0 then it should be delete.

    Please give me some instructions.

    Thanks in Advance

    Sarfaraj Ahmed

  • Make a job and schedule it to run every 20 minutes.

    Then in the job, simply do a

    Delete FROM Orders WHERE datediff... >= 20

    Search for datediff in bols for exact syntax and parameters.

  • Thanks for your quick reply

    could you please give me more description, like where i need to write code

  • Ninja's_RGR'us (2/22/2009)


    Make a job and schedule it to run every 20 minutes.

    Then in the job, simply do a

    Delete FROM Orders WHERE datediff... >= 20

    Search for datediff in bols for exact syntax and parameters.

    I need more description, how i will run it every 20 minutes

  • management studio >

    Open your server >

    SQL server Agent >

    jobs >

    Right click for all your options

  • Ninja's_RGR'us (2/22/2009)


    management studio >

    Open your server >

    SQL server Agent >

    jobs >

    Right click for all your options

    Thnaks

    I bought some database space and I dont have any permission to setup SQL Agents.

    Is their any other way I can do it

    For example computed column it checks the value from a column.

    Is their any functions that can auto check rows

  • You can make a script like this and start it... then just forget about it :

    while 0 = 0

    begin

    Delete FROM...

    waitfor delay '00:20:00'

    end

    I don't know any way to keep this connection alive unless you start it from a vbs script on a 24/7 computer.

    Maybe you can simulate this if you run this withing and EXEC() statement with dynamic sql. But then again, how do you know it it,s still running without doing manual check... maybe you could be a web page and run it every once in a while. But that's the same problem, how do you schedule it...

  • Ninja's_RGR'us (2/22/2009)


    You can make a script like this and start it... then just forget about it :

    while 0 = 0

    begin

    Delete FROM...

    waitfor delay '00:20:00'

    end

    I don't know any way to keep this connection alive unless you start it from a vbs script on a 24/7 computer.

    Maybe you can simulate this if you run this withing and EXEC() statement with dynamic sql. But then again, how do you know it it,s still running without doing manual check... maybe you could be a web page and run it every once in a while. But that's the same problem, how do you schedule it...

    Anyway thanks for your feedback

  • You're giving up already????

    My solution will work, you just need to figure out a way to make a permanent connection to the server without tying up someone or a computer 24_7.

    Let me know what you find and how you implemented this.

  • Ninja's_RGR'us (2/22/2009)


    You're giving up already????

    My solution will work, you just need to figure out a way to make a permanent connection to the server without tying up someone or a computer 24_7.

    Let me know what you find and how you implemented this.

    Thank you very much.

    I can do now

  • Ninja's_RGR'us (2/22/2009)


    You're giving up already????

    My solution will work, you just need to figure out a way to make a permanent connection to the server without tying up someone or a computer 24_7.

    Let me know what you find and how you implemented this.

    As I think is:

    on order.aspx page load event i will execute a query to check previous order status, then delete as i need

Viewing 11 posts - 1 through 10 (of 10 total)

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