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 |
|
inbs
Aged Yak Warrior
860 Posts |
Posted - 2011-10-23 : 10:49:20
|
i have aggregate table:how do i delete last two month every day ?(i know insert last two month i have that date in the row)month year 01 200902 200903 2009...11 200912 200901 201002 201003 2010... |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-23 : 10:56:27
|
| [code]DELETEFROM tableWHERE month IN (DATEPART(mm,DATEADD(mm,DATEDIFF(mm,0,GETDATE())-1,0)),DATEPART(mm,DATEADD(mm,DATEDIFF(mm,0,GETDATE())-2,0)))AND year IN (DATEPART(yy,DATEADD(mm,DATEDIFF(mm,0,GETDATE())-1,0)),DATEPART(yy,DATEADD(mm,DATEDIFF(mm,0,GETDATE())-2,0)))[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|