Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2006
    Posts
    16

    Unanswered: Remove duplicate rows from table

    I have a table with one column, and i want to remove those records from the table which are duplicate i meant if i have a records rakesh in table two time then one records should be remove...
    my tables is like that

    Names
    ------------
    Rakesh
    Rakesh
    Rakesh Kumar Sharma
    Rakesh Kumar Sharma
    Baburaj
    Raghu
    Raghu

    and Output of query should be like that
    Names
    -----------
    Rakesh
    Rakesh Kumar Sharma
    Baburaj
    Raghu

    Thanks in advance

  2. #2
    Join Date
    Nov 2005
    Location
    San Francisco, CA
    Posts
    506
    SELECT * FROM table1
    UNION
    SELECT * FROM table1
    or
    SELECT distinct name FROM table1

    ....

    Plz give the whole structure of your table,then only we can help you.Plz read the sticky above in this forum.
    Last edited by rudra; 03-20-07 at 04:36.
    Success is the ability to go from one failure to another with no loss of enthusiasm.
    - Sir Winston Churchill
    Joydeep

  3. #3
    Join Date
    Jan 2005
    Posts
    28
    Hi,

    You can find three methods with samples for removing dublicated records from tables at article http://www.kodyaz.com/articles/delet...n-a-table.aspx

    One method is using "SET ROWCOUNT", an other method uses the "TOP". And the last way of solving this problem is getting use of a temporary "IDENTITY" column.

    I hope you find it useful

    Eralper
    http://www.kodyaz.com

  4. #4
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    As always, make a back-up first!
    Code:
    select	distinct *
    into	#temptable
    from	yourtable
    
    delete	from yourtable
    
    insert	into yourtable
    select	*
    from	#temptable
    
    drop	table #temptable
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •