In this example we are going to remove some duplicate records from the sql server table.
According to below screen shot few records has been duplicated.
By executig below script you can remove the duplicate records.
According to below screen shot few records has been duplicated.
By executig below script you can remove the duplicate records.
--Insert distinct records to temporary table
select distinct * into #temp From [dbo].[Products]
--delete all records from [dbo].[Products]
delete from [dbo].[Products]
--insert distinct records from temp table to [dbo].[Products]
insert into [dbo].[Products]
select * from #temp
--drop the temp table
drop table #temp
--output you can see
select * from [dbo].[Products]
Removing duplicates records in SQL Server table
Reviewed by Pubudu Dewagama
on
12:26:00 AM
Rating:
No comments: