469,360 Members | 2,281 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,360 developers. It's quick & easy.

Delete Duplicate Columns

Create table info(comp_id int identity(101,1),comp_name varchar(50))
insert into info values('Progressive Ltd.')
insert into info values('Progressive Ltd.')
insert into info values('EliResearch')
insert into info values('Patni')
insert into info values('Accenture')
insert into info values('Accenture')
select * from info

I want to delete those entries from the table that have duplicate company names.
I m not getting it,Plz reply.
Apr 15 '08 #1
2 7774
deepuv04
227 Expert 100+
Create table info(comp_id int identity(101,1),comp_name varchar(50))
insert into info values('Progressive Ltd.')
insert into info values('Progressive Ltd.')
insert into info values('EliResearch')
insert into info values('Patni')
insert into info values('Accenture')
insert into info values('Accenture')
select * from info

I want to delete those entries from the table that have duplicate company names.
I m not getting it,Plz reply.
hi
try the following query

Expand|Select|Wrap|Line Numbers
  1. DELETE FROM [info] 
  2. WHERE [comp_name] IN
  3. (SELECT [comp_name] FROM [info] 
  4. GROUP BY [comp_name] HAVING COUNT([comp_name]) > 1)
  5.  
Apr 15 '08 #2
Thanks,
it worked.
Apr 15 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Carroll | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.