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 |
|
Vack
Aged Yak Warrior
530 Posts |
Posted - 2008-09-06 : 11:57:54
|
| Have table orderrebateord_type,ord_no,item_no,line_seq_no,Cd_tpIf I have 3 rows that are identical I want to delete 2 and keep 1 of them. |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2008-09-06 : 12:04:42
|
| Guess this has been answeredhttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=110167 |
 |
|
|
ma.voice
Starting Member
12 Posts |
Posted - 2008-09-06 : 13:45:16
|
| Try following code:CREATE TABLE #emp(empno int,ename varchar(100),deptno int)GOINSERT INTO #emp values (1,'A',9)INSERT INTO #emp values (1,'A',9)INSERT INTO #emp values (1,'A',9)INSERT INTO #emp values (1,'A',9)GOSELECT * FROM #empGODELETE TFROM(SELECT TOP 3 * FROM #emp ) as TSELECT * FROM #empGODROP TABLE #empGOHopefully this will solve your problemCheers.Silent VoiceBill Gates, MVP |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-09-06 : 15:05:36
|
DELETE fFROM (SELECT ROW_NUMBER() OVER (PARITION BY ord_type, ord_no, item_no, lin_seq_no ORDER BY cd_tp) AS RecID) AS fWHERE RecID > 1 E 12°55'05.63"N 56°04'39.26" |
 |
|
|
|
|
|
|
|