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 |
|
SamC
White Water Yakist
3467 Posts |
Posted - 2003-11-04 : 22:03:25
|
| CREATE TABLE MyTable (MyID INT,CreateDate DATETIME)What's the simplest DELETE of all rows saving only the most current CreateDate for each value if MyID?Sam |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2003-11-04 : 22:24:28
|
| DELETE FROM MyTableFROM MyTableINNER JOIN MyTable M2 ON M2.MyID = MyTable.MyID and M2.CreateDate > MyTable.CreateDateDamian |
 |
|
|
SamC
White Water Yakist
3467 Posts |
Posted - 2003-11-04 : 22:33:03
|
Thanks Merkin Sam |
 |
|
|
SamC
White Water Yakist
3467 Posts |
Posted - 2003-11-04 : 22:56:37
|
I kind'a like this syntax:DELETE A FROM dbo.Feedback2 A INNER JOIN dbo.Feedback2 B ON A.CourseID=B.CourseID AND A.UserID=B.UserID AND A.FormID=B.FormID AND A.CreateDate < B.CreateDate Didn't know an alias would work on a delete till now.Sam |
 |
|
|
|
|
|