Results 1 to 2 of 2

Thread: Date Problem in SQL Server

  1. #1
    Join Date
    May 2006
    Posts
    1

    Smile Date Problem in SQL Server

    Hi,

    I'm very new to SQL Server. I have an issue.

    I should create a job which is running on month end that deletes all the records upto 2 months before. For eg. if the job is running at May 31st, all records upto March 31st should delete. How should I do that. Please send me the code for the same.


    Thanks

    Rajaraman S.

  2. #2
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    if your database name is AAA if your table name is BBB and has a date column CCC then the code will look like

    use AAA
    go
    delete from BBB where CCC <=dateadd(m,-2,getdate())

Posting Permissions

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