Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2003
    Posts
    17

    Unanswered: Old data from mdf deleting problem again!

    Hello Guys!

    Thanks for your previous posts to me, but I'm still in trouble.
    I have card.mdf file and I need to delete data older than 3
    months from the table called Events.
    I tried the following:

    use card.mdf
    delete from Events where datediff(m,Field Time,getdate()) >= 3

    "Field date" is the name of the colums where dates are logged.
    But in query analyser it says that there is an error near "Time"
    What am I doing wrong.

    Please help me,
    Jessica

  2. #2
    Join Date
    Jul 2003
    Location
    England
    Posts
    152
    I suspect that your problem is caused because of the space in the "Field Time" column name. I think you will need to put quotes around this column and try again.
    Regards
    Dbabren

  3. #3
    Join Date
    Jul 2003
    Location
    England
    Posts
    152
    Originally posted by dbabren
    I suspect that your problem is caused because of the space in the "Field Time" column name. I think you will need to put quotes around this column and try again.
    Sorry, I meant square brackets (doh!)

    ie
    delete from Events where datediff(m,[Field Time],getdate()) >= 3
    Regards
    Dbabren

  4. #4
    Join Date
    Sep 2003
    Posts
    17
    Thanks a lot dbabren, It now worked.
    But do you know How I could run this
    from dos command line?

    Jessica

  5. #5
    Join Date
    Jul 2003
    Location
    England
    Posts
    152
    Jessica

    I assume that you mean it works via osql. I don't know is the short answer! I can only assume that the Syntax checker is not as strict in osql as it is in Query Analyser.
    Regards
    Dbabren

  6. #6
    Join Date
    Sep 2003
    Location
    Belgium
    Posts
    2

    Re: Old data from mdf deleting problem again!

    Try this

    use card.mdf
    delete from Events where datediff(m,[Field Time],getdate()) >= 3

    add [ ] around your column name.

Posting Permissions

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