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 |
|
sqlchiq
Posting Yak Master
133 Posts |
Posted - 2008-08-25 : 14:30:27
|
| deletefrom carnivalshipnames t,(select max(executiondatetime) as executiondatetimefrom carnivalshipnames) rwhere not t.executiondatetime = r.executiondatetime or t.executiondatetime is nullis not working. It gives this errorMsg 102, Level 15, State 1, Line 2Incorrect syntax near 't'.Msg 102, Level 15, State 1, Line 4Incorrect syntax near 'r'.but!select *from carnivalshipnames t,(select max(executiondatetime) as executiondatetimefrom carnivalshipnames) rwhere not t.executiondatetime = r.executiondatetime or t.executiondatetime is nullIS working.... I don't understand why one wolud work but not the other |
|
|
sqlchiq
Posting Yak Master
133 Posts |
Posted - 2008-08-25 : 14:35:26
|
| The point of this delete statement is to keep only the newest set of data in the table.it finds the newest date in column executiondatetime via max(executiondatetime), then it should delete every entry that does not have a date of max(executiondatetime) |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2008-08-25 : 14:55:22
|
It isn't working because it's invalid syntaxdelete t from carnivalshipnames t...etc. CODO ERGO SUM |
 |
|
|
|
|
|