Tuesday, January 5, 2010

Show duplicate rows and delete duplicate rows

Show:
select customerid from tbl_customer group by customerid having count(customerid)>1
it will give u duplicate customerid in that particular table
Delete:
Here table name:tbl_places...columns:place
now add one identity column to this table
alter table tbl_places add I int identity
now delete
delete from tbl_places where I NOT IN(select min(i) from tbl_places group by place)

No comments:

Post a Comment