• Tej_7342 (11/5/2013)


    i have to delete data from a table which is older than 2 weeks, how can i use a cursor to do it.

    Why does it have to be a cursor?

    Could you do something like this:

    delete from Table1 where Table1.DateTimeColumn < dateadd(ww, -2, getDate())

    This would need to be tweaked to account for the time component. Other than that, this would run MUCH faster than any cursor.

    __________________________________________________________________________________________________________
    How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/