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 |
wsilage
Yak Posting Veteran
82 Posts |
Posted - 2014-09-17 : 14:11:45
|
I have a table that I need to delete the oldest date. I thought I could just do an update statement saying...Delete T_BreakDownwhere Date = MIN(Date)But that doesn't work.Any suggestion, would be great!Thanks |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2014-09-17 : 14:18:23
|
[code];WITH cte AS( SELECT TOP (1) * FROM T_BreakDown ORDER BY Date)DELETE cte;[/code] |
|
|
wsilage
Yak Posting Veteran
82 Posts |
Posted - 2014-09-17 : 14:55:15
|
When I did this;WITH cte AS( SELECT TOP (2) * FROM T_AXA_BreakDown_Claims_2 ORDER BY [Todays Date])DELETE T_AXA_BreakDown_Claims_2;It deleted everything in my test file (which is okay), but how do I do it so it only take my earliest date? |
|
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2014-09-17 : 16:12:43
|
quote: Originally posted by wsilage When I did this;WITH cte AS( SELECT TOP (2) * FROM T_AXA_BreakDown_Claims_2 ORDER BY [Todays Date])DELETE T_AXA_BreakDown_Claims_2 cte;It deleted everything in my test file (which is okay), but how do I do it so it only take my earliest date?
|
|
|
wsilage
Yak Posting Veteran
82 Posts |
Posted - 2014-09-18 : 09:36:11
|
Thank you so much this helped me out a lot! |
|
|
|
|
|