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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-03-12 : 23:05:11
|
| Riaz Ahmed Farooqui writes "How Can I Delete Duplicate Record In One Table through Query.For Example Table is Customer Code Customer Name1 Riaz 1 Riaz2 Aleem2 Aleem3 Kaleem3 Kaleem4 Naeem4 Naeem" |
|
|
graz
Chief SQLTeam Crack Dealer
4149 Posts |
Posted - 2002-03-12 : 23:05:11
|
| A quick search of the site (which we always suggest you do before posting a question) turns up this article (http://www.sqlteam.com/item.asp?ItemID=3331) which is titled "Deleting Duplicate Records." |
 |
|
|
jhun_garma
Starting Member
15 Posts |
Posted - 2002-03-12 : 23:42:05
|
| try thisselect * from tableunionselect * from table where ( a conditon that gives 0 records )the union statements join two tables then delete all duplicates |
 |
|
|
rrb
SQLTeam Poet Laureate
1479 Posts |
Posted - 2002-03-13 : 00:12:08
|
| Riaz AhmedYou might also be looking for select distinct CustomerCode, CustomerName from CustomerCheers--I hope that when I die someone will say of me "That guy sure owed me a lot of money"Edited by - rrb on 03/13/2002 00:13:19 |
 |
|
|
byrmol
Shed Building SQL Farmer
1591 Posts |
Posted - 2002-03-13 : 00:12:56
|
Riaz,Try this for a quick a dirty solution....set rowcount 1declare @Code intSelect 1while @@RowCOunt > 0begin Delete Customer from Customer C where exists (Select Code from Customer where Code = C.Code group by Code having Count(*) > 1)end Nice one jhun_garma..Except you don't need the where clause on the lower unionSelect * from TableunionSelect * from Table It doesn't actual "delete" rows.. just "hides" them from the setDavidMTomorrow is the same day as Today was the day before. |
 |
|
|
|
|
|