By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,203 Members | 1,383 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,203 IT Pros & Developers. It's quick & easy.

using Sql 2005 EE need to truncate not delete table data older than 15 days old

P: 2
I am using Sql server 2005 Express edition
(Need to retain Table comport Data for 15days)
I am attempting to Truncate (not delete) data that is older than 15 days based on the MyDate Column within this table.
My specific Example would be based on Database 43577
& the Table would be dbo.comport
The only script that I can find for this is similar to what I have Below:
truncate table comport
Where MyDate <=dateadd(day, -15, getdate())

However this results in:
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'Where'.

I am very very new to sql & this task was just dumped on me, I am now catching a lot of heat so I`m hoping someone can help me out here..
Thanks in advance
Please advise if there is anything else I should provide.
Apr 23 '11 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 1,206
Try the Microsoft Server SQL forum. Perhaps a mod could move this there.
Apr 25 '11 #2

P: 2
thanxs but in reality I beleif that a truncate statement
always applies to the entire table, so maybe its not possible to do as I request...
I will go with a delete statement..
thanxxxx for the reply
May 4 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.