Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get all records except the latest
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01356683
Message ID:
01356735
Views:
25
>>I need to update all duplicates by FK and Flag = 1 to set flag = 0 except for the latest by Date1 and Date2. I already did it by procedural code, but curious if it's possible to get the records to update by SQL.
>
>Basically you will be updating your table using the PK from ..
>
>selecting TOP 1 PK from (your duplicate selection statement) order by Date1 desc
>
>and
>
>selecting TOP 1 PK from (your duplicate selection statement) order by Date2 desc

Not exactly. I need to update all records which are duplicates except for the top 1. I guess in SQL Server you can use CTE to get all duplicates.

Still a bit tricky.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform