Monday, February 20, 2012

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,
JessicaI 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.|||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|||Thanks a lot dbabren, It now worked.
But do you know How I could run this
from dos command line?

Jessica|||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.|||Try this

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

add [ ] around your column name.

No comments:

Post a Comment