Exforsys

Online Training

duplicate rows

This is a discussion on duplicate rows within the SQL Server 2005 Tutorials forums, part of the Articles and Tutorials category; Pls anybody answer for this question: How to delete duplicate rows in a table?(in sql server db)...


Go Back   Exforsys > Articles and Tutorials > SQL Server 2005 Tutorials

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-29-2008, 03:32 AM
Junior Member
 
Join Date: Mar 2008
Posts: 12
bobby21 is on a distinguished road
duplicate rows

Pls anybody answer for this question:
How to delete duplicate rows in a table?(in sql server db)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-16-2008, 05:02 AM
Junior Member
 
Join Date: Apr 2008
Posts: 7
jagadishbabub is on a distinguished road
Hi

Can u send some more details, like
whether the table is having primary key,
duplicate means the entire row.

If possible can u send the table structure and sample data
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-18-2008, 01:54 AM
Junior Member
 
Join Date: Mar 2008
Posts: 12
bobby21 is on a distinguished road
Deleting duplicate rows........from the following table

Quote:
Originally Posted by jagadishbabub View Post
Can u send some more details, like
whether the table is having primary key,
duplicate means the entire row.

If possible can u send the table structure and sample data

ThankYou for your reply Mr.Jagdish. The table is as follows:

empno empname

10 balu
10 balu
20 ravi
30 gopi
30 gopi
30 gopi

so,,,please tell me how to delete duplicate rows in sql server 2000/2005.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-21-2008, 04:29 AM
Junior Member
 
Join Date: Apr 2008
Posts: 7
jagadishbabub is on a distinguished road
I think instead of trying to do it in a single query, we can use a stored procedure. Is there any restriction not to use a Stored procedure ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-21-2008, 12:31 PM
Junior Member
 
Join Date: Mar 2008
Posts: 12
bobby21 is on a distinguished road
okay mate

Quote:
Originally Posted by jagadishbabub View Post
I think instead of trying to do it in a single query, we can use a stored procedure. Is there any restriction not to use a Stored procedure ?
no problem.....can tell me that way using stored procedure
cheers mate
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-22-2008, 02:47 AM
Junior Member
 
Join Date: Apr 2008
Posts: 7
jagadishbabub is on a distinguished road
Hi Bobby

Below is the code for Sample procedure to eliminate duplicate rows.
Though this is a bad solution ........ It will work.
I am trying to find a good solution, but it is giving some errors.
So if it is very urgent ......... you can use the following code .......

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


Very soon I will post u a best solution.
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 threads
You may not post replies
You may not post attachments
You may not edit your posts

BB 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
delete the duplicate sandeeppradhan SQL Server 2 04-23-2008 05:23 AM
Eliminating Duplicate Rows from Flat File cyrus Data Warehousing 2 08-24-2007 09:16 AM
Retain Duplicate cyrus DB2 1 03-13-2007 11:09 PM
How to delete duplicate rows from a table athermaliq Oracle Tutorials 5 01-17-2006 01:03 AM
[FAQ] FileMaker Pro - database for Macintosh and Windows Martin Trautmann Tech FAQ 0 04-17-2004 08:26 AM


All times are GMT -4. The time now is 04:23 PM.


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