Exforsys

Online Training

delete the duplicate

This is a discussion on delete the duplicate within the SQL Server forums, part of the Database category; How to delete the duplicate row from a table without using cursor in microsoft sql server If any one know ...


Go Back   Exforsys > Database > SQL Server

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-11-2008, 02:27 AM
sandeep babu
 
Join Date: Jan 2008
Location: India(Bangalore)
Posts: 3
sandeeppradhan is on a distinguished road
delete the duplicate

How to delete the duplicate row from a table without using cursor in microsoft sql server
If any one know then please send me the answer
Thank you
sandeep kumar pradhan
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-22-2008, 02:21 AM
Junior Member
 
Join Date: Apr 2008
Posts: 7
jagadishbabub is on a distinguished road
Hi Sandeep,

Trying out for a best solution but is giving some error...........
Meanwhile if it is very urgent ........ you can use this .........
ofcourse this is not recommended ..........

CREATE PROCEDURE dbo.PROC_Eliminate_Duplicate_Rows
AS
SET NOCOUNT ON
CREATE TABLE #TBL_Duplicate (EMPNo int, EMPName varchar(50))
INSERT INTO #TBL_Duplicate SELECT DISTINCT * FROM EMP_Duplicate
DELETE EMP_Duplicate
INSERT INTO EMP_Duplicate SELECT * FROM #TBL_Duplicate
SELECT * FROM EMP_Duplicate
RETURN



Regards,
Jagadish Babu
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-23-2008, 04:23 AM
Junior Member
 
Join Date: Dec 2007
Posts: 2
srichandr is on a distinguished road
Hai Sandeep,

Please try

SET ROWCOUNT 1
DELETE temp_test
FROM temp_test a
WHERE (SELECT COUNT(*) FROM temp_test b WHERE b.name = a.name and b.value = a.value) > 1
WHILE @@rowcount > 0
DELETE temp_test
FROM temp_test a
WHERE (SELECT COUNT(*) FROM temp_test b WHERE b.name = a.name and b.value = a.value) > 1
SET ROWCOUNT 0


Regards,
Srichand
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new questions
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
Eliminating Duplicate Rows from Flat File cyrus Data Warehousing 2 08-24-2007 08:16 AM
Retain Duplicate cyrus DB2 1 03-13-2007 10:09 PM
How to delete duplicate rows from a table athermaliq Oracle Tutorials 5 01-17-2006 12:03 AM
Looking for a utility that will delete middle directories mraymus Software Patterns 1 06-16-2004 03:44 PM
[FAQ] FileMaker Pro - database for Macintosh and Windows Martin Trautmann Tech FAQ 0 04-17-2004 07:26 AM


All times are GMT -4. The time now is 07:09 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.