Author |
Topic |
jafrywilson
Constraint Violating Yak Guru
379 Posts |
Posted - 2010-10-07 : 06:32:45
|
Hi all.. I have a table which contains details for 30 days .. I want to keep last 7 days only ..Others must be deleted..How to do this ?. |
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-10-07 : 06:35:45
|
And the table looks like? There is some sort of timestamp column?Read your question again and think"I know nothing but the question. Can I solve it? NO"Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
Sachin.Nand
2937 Posts |
Posted - 2010-10-07 : 06:36:12
|
How do your store the dates in the table & what is the format?PBUH |
 |
|
jafrywilson
Constraint Violating Yak Guru
379 Posts |
Posted - 2010-10-07 : 06:46:30
|
While inserting the values i used getdate() function to insert values in the table.. |
 |
|
jafrywilson
Constraint Violating Yak Guru
379 Posts |
Posted - 2010-10-07 : 06:47:35
|
can u help me on this topic http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=151146 |
 |
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-10-07 : 06:53:21
|
Please learn HOW TO ASK A QUESTION.please read this.http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxDo you understand that we *can't* help you with the information you've given us. We *don't* know your table structure or the data so we *can't* tell you what to do.Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
Sachin.Nand
2937 Posts |
Posted - 2010-10-07 : 06:54:59
|
[code]delete from yourtable where dateadd(dd,DATEDIFF(dd,0,yourcolumn),0)not betweendateadd(dd,DATEDIFF(dd,0,getdate()),0)-7 and dateadd(dd,DATEDIFF(dd,0,getdate()),0)[/code]PBUH |
 |
|
jafrywilson
Constraint Violating Yak Guru
379 Posts |
Posted - 2010-10-07 : 07:01:43
|
quote: Originally posted by Sachin.Nand
delete from yourtable where dateadd(dd,DATEDIFF(dd,0,yourcolumn),0)not betweendateadd(dd,DATEDIFF(dd,0,getdate()),0)-7 and dateadd(dd,DATEDIFF(dd,0,getdate()),0) PBUH
Tnx for your help ... |
 |
|
jafrywilson
Constraint Violating Yak Guru
379 Posts |
Posted - 2010-10-07 : 07:13:57
|
quote: Originally posted by Transact Charlie Please learn HOW TO ASK A QUESTION.please read this.http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxDo you understand that we *can't* help you with the information you've given us. We *don't* know your table structure or the data so we *can't* tell you what to do.Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
I think i gave all the details about my table.. |
 |
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-10-07 : 08:03:26
|
No you didn't!You saidquote: Hi all..I have a table which contains details for 30 days ..I want to keep last 7 days only ..Others must be deleted..How to do this ?.
and Sachin made a *guess* that you'd have some column to keep track of the date. You could have had *anything* in that table.I'm sorry but you are simply bad at giving us information to base answers on which is why your other topics haven't been answered yet. You don't post table structures, you don't give sample data.....You had enough posts now that you should be able to ask a proper question.Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
Sachin.Nand
2937 Posts |
Posted - 2010-10-07 : 08:21:03
|
@jafrywilsonCome on with 274 posts you need to atleast know how to post the question.Now just look at thishttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=151146#594185How can one understand what you want?It's like a guess work which you think we seem to enjoy.I totally agree with Charlie on this.It's urgency on your part not on ours.So please try to be more specific from next time.If you can please post the sample o/p for the question you had in the link I posted above.PBUH |
 |
|
jafrywilson
Constraint Violating Yak Guru
379 Posts |
Posted - 2010-10-07 : 10:20:47
|
From the next time itself i will try my best to ask a question with full details ...Communication is my first disadvantage for this kind of problem problem ...I will try improve myself ..Thanks for the response... |
 |
|
|