
- Forum
- Database
- SQL Server
- duplicate rows
duplicate rows
This is a discussion on duplicate rows within the SQL Server forums, part of the Database category; Pls anybody answer for this question: How to delete duplicate rows in a table?(in sql server db)...
-
duplicate rows
Pls anybody answer for this question:
How to delete duplicate rows in a table?(in sql server db)
-
04-16-2008, 05:02 AM #2
- Join Date
- Apr 2008
- Answers
- 7
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
-
Deleting duplicate rows........from the following table
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.
-
04-21-2008, 04:29 AM #4
- Join Date
- Apr 2008
- Answers
- 7
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 ?
-
-
04-22-2008, 02:47 AM #6
- Join Date
- Apr 2008
- Answers
- 7
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.
-
Sponsored Ads

Reply With Quote






