Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2004
    Posts
    38

    Unanswered: remove duplicae data

    Hi All,


    I have information as following:


    Name Age ID
    Frew 11 3333333
    Freni 23 3333323
    Frew 11 3333333

    As you can see first row and third row contain same record, how could I remove it?

    Thanks

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    select distinct Name,Age,ID into newtable from oldtable
    drop table oldtable
    exec sp_rename 'newtable', 'oldtable'
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    May 2002
    Posts
    299
    In addition to Rudy's, you can try this:

    http://support.microsoft.com/default...b;en-us;139444
    --
    -oj
    http://www.rac4sql.net

  4. #4
    Join Date
    Apr 2004
    Posts
    38
    Thanks guys it works

  5. #5
    Join Date
    Oct 2003
    Posts
    357
    >>select distinct Name,Age,ID into newtable from oldtable

    Because the newtable wont have any indices or contraints that oldtable have, it is better to script the structure of the oldtable and rename table name and run and then this query

    Insert into newtable(Name,Age,ID) Select Distinct Name,Age,ID from oldtable
    Madhivanan

    Failing to plan is Planning to fail

  6. #6
    Join Date
    Apr 2004
    Posts
    38
    Thank you for providing useful information
    If I have 10 records, do I have to run the insert command 10 times?

    Thanks

  7. #7
    Join Date
    Oct 2003
    Posts
    357
    No Only that Single select will insert all the rows
    Madhivanan

    Failing to plan is Planning to fail

Posting Permissions

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