• Home
  • About Me
  • Resume
  • Useful Links
  • Português
  • Contact

EmanuelCosta.com

E-Commerce, SEO/SEM/Online Marketing, Web Development, Usability, WordPress & WooCommerce

  • LinkedIn
  • Twitter
Home » Archives for July 17, 2007

Archives for July 17, 2007

Removing duplicated values from a table / Removendo valores duplicados de uma tabela

Posted on July 17, 2007 Written by EmanWeb

In T-SQL you may use “insert” to remove duplicates. What you must do is create another work table with the IGNORE_DUP_KEY option set.

So you copy the data from one table to the other. Drop the original table and rename the work table to your original table name and that's it. You will have a plain, clean, non duplicated records table. Something like:


CREATE TABLE tableCleanDup
(idfield int, field1 varchar(30), field2 varchar(30))
CREATE UNIQUE INDEX removeduplicates ON tableCleanDup (field1,field2) WITH IGNORE_DUP_KEY
GO
INSERT tableCleanDup SELECT * FROM tableOriginal

It will return to you a message “duplicate key was ignored” but that is fine. The tableCleanDup will have the records from tableOriginal but without duplicates.

p.s.: Thanks to Ken Henderson for this T-SQL advice.

Vers

  • delicious Bookmark on Delicious
  • digg Digg this post
  • facebook Recommend on Facebook
  • linkedin Share on Linkedin
  • reddit share via Reddit
  • stumble Share with Stumblers
  • twitter Tweet about it
  • rss Subscribe to the comments on this post
  • print Print for later
  • email Tell a friend

Filed Under: SQL Server and T-SQL

Find Here

About me

Hello, my name is Emanuel Costa. I build professional websites and help companies grow online. I write this blog to help myself about what I learned and perhaps help other people. I help organize meetups and whenever I can I attend tech events, specially WordCamps. Read more about me. (p.s.: Agora escrevo um blog em Português aqui: emanweb.com.br

Latest WordCamp:

WordCamps I Attended:

I am volunteering at WordCamp Las Vegas 2019″ title=

WordCamp Fortaleza

I'm attending WordCamp San Diego

I am Attending WordCamp Miami 2016


WordCamp US

Categories

  • ActionScript
  • Blogs
  • ColdFusion
  • CSS
  • Experience
  • Flex and Flash
  • Gadgets
  • Google
  • JavaScript
  • Linux
  • MySQL
  • PHP
  • SEO
  • SEO and Internet Marketing
  • SQL Server and T-SQL
  • Uncategorized
  • video
  • Web Development
  • WooCommerce
  • wordcamp
  • WordPress
July 2007
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  
    Aug »

Recent Comments

  • Peter Crouch on How to output a list of IDs in a field as recordsets / Como retornar uma lista de IDs como recordset
  • Simon on cPanel on AWS EC2 using Amazon Linux w/ Yours Nameservers
  • WordPress Developer? Really? - EmanuelCosta.com on Gracie Brazilian Jiu Jitsu and WordPress. What these two have in common?

Follow Me

  • Linkedin
  • Meetup
  • RSS feed
  • @emanweb

Navigation

  • Home
  • About Me
  • Resume
  • Useful Links
  • Português
  • Contact

Need quick tech advice? Pick my brain:

Copyright © 2025 · Focus Pro Theme on Genesis Framework · WordPress · Log in