Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 remove duplicates on a table

Author  Topic 

Msandlana
Starting Member

33 Posts

Posted - 2008-01-29 : 09:38:10
Hi All
I have the dbo.OperatingHour It has many duplicates and I want to remove duplicates permanently
The statement below works but when I open the table there are no changes

Insert into OperatingHour(Weekdays, Wednesdays, Fridays,Saturdays, [Sundays/Public Holidays])
(SELECT DISTINCT Weekdays, Wednesdays, Fridays,Saturdays, [Sundays/Public Holidays] FROM OperatingHour)

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-01-29 : 09:40:19
SELECT DISTINCT Weekdays, Wednesdays, Fridays,Saturdays, [Sundays/Public Holidays] INTO #Temp FROM OperatingHour
GO

TRUNCATE TABLE OperatingHour
GO

INSERT OperatingHour (Weekdays, Wednesdays, Fridays,Saturdays, [Sundays/Public Holidays])
SELECT Weekdays, Wednesdays, Fridays,Saturdays, [Sundays/Public Holidays] FROM #Temp
GO

DROP TABLE #Temp
GO




E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

Msandlana
Starting Member

33 Posts

Posted - 2008-01-29 : 10:18:21
thanks peso
Go to Top of Page
   

- Advertisement -