472,129 Members | 1,598 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,129 software developers and data experts.

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 8561
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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.