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 |
|
arielspecial
Starting Member
11 Posts |
Posted - 2010-06-29 : 04:09:48
|
| Hi, I have tried to create this script, but got stuck:for each userID in a table(there are multiple times the same userID) I want to get all the records where for this userID delete all records with the same dateInserted column except one. if I have 5 times the same userID and same date delete only 4 records. |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
|
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-06-29 : 05:04:20
|
| If that is confusing for you to get the solution quickly then Try this -But the topic may give you more information than your need...;WITH CTE AS(SELECT *, ROW_NUMBER() OVER ( Partition By UserID, Date ORDER BY UserID ) Seq FROM TableName)DELETE FROM CTE WHERE Seq <> 1Vaibhav TTo walk FAST walk ALONE To walk FAR walk TOGETHER |
 |
|
|
|
|
|