Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sent_sara
Constraint Violating Yak Guru
377 Posts |
Posted - 2008-07-21 : 01:22:06
|
| Can any one correct my query,If iam wrong.I need to delete those record which is less than 10 days from the current date.After the insertion happens in status_report table.Create trigger trg_status_report on status_reportfor insert --After in--(??)as begindelete from fin_wh.dbo.status_reportwhere datediff(dd,getdate()-4,st_date)<2end |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-07-21 : 01:26:07
|
"I need to delete those record which is less than 10 days from the current date"less than 10 days ?delete dfrom status_report dwhere d.st_date >= dateadd(day, datediff(day, 0, getdate()), -10) KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
sent_sara
Constraint Violating Yak Guru
377 Posts |
Posted - 2008-07-21 : 01:33:12
|
I need to delete after the insertion happens to the table[status_report].whether after insert keyword need to be incorporate in trigger???quote: Originally posted by khtan "I need to delete those record which is less than 10 days from the current date"less than 10 days ?delete dfrom status_report dwhere d.st_date >= dateadd(day, datediff(day, 0, getdate()), -10) KH[spoiler]Time is always against us[/spoiler]
|
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-07-21 : 01:40:18
|
[code]CREATE trigger trg_status_report ON status_report FOR INSERT ASBEGIN DELETE d FROM status_report d WHERE d.st_date >= DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), -10)END[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
sent_sara
Constraint Violating Yak Guru
377 Posts |
Posted - 2008-07-21 : 01:50:24
|
txs khtanquote: Originally posted by khtan
CREATE trigger trg_status_report ON status_report FOR INSERT ASBEGIN DELETE d FROM status_report d WHERE d.st_date >= DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), -10)END KH[spoiler]Time is always against us[/spoiler]
|
 |
|
|
|
|
|
|
|