Exforsys
+ Reply to Thread
Results 1 to 6 of 6

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)...

  1. #1
    bobby21 is offline Junior Member Array
    Join Date
    Mar 2008
    Answers
    10

    duplicate rows

    Pls anybody answer for this question:
    How to delete duplicate rows in a table?(in sql server db)


  2. #2
    jagadishbabub is offline Junior Member Array
    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



  3. #3
    bobby21 is offline Junior Member Array
    Join Date
    Mar 2008
    Answers
    10

    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.


  4. #4
    jagadishbabub is offline Junior Member Array
    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 ?


  5. #5
    bobby21 is offline Junior Member Array
    Join Date
    Mar 2008
    Answers
    10

    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


  6. #6
    jagadishbabub is offline Junior Member Array
    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



Latest Article

Network Security Risk Assessment and Measurement

Read More...