I want to check the duplicate values in my SQL table. and remove those data.
So I first checked the duplicate values using
SELECT COUNT(*)
[Se_Id],
[Service_Previous_Step],
[Service_Next_Step]
FROM [Mondo-PROD].[dbo].[ServiceWorkflows]
GROUP BY
[Se_Id],
[Service_Previous_Step],
[Service_Next_Step]
HAVING COUNT(*) > 1;
Then I use this
ALTER TABLE [dbo].[ServiceWorkflows]
ADD CONSTRAINT UQ_ServiceWorkflows_ServiceId_PreviousStep_NextStep
UNIQUE ([Service_Id], [Service_Previous_Step], [Service_Next_Step]);
But I get errors as
The CREATE UNIQUE INDEX statement terminated because a duplicate key was found for the object name 'dbo.ServiceWorkflows' and the index name 'UQ_ServiceWorkflows_ServiceId_PreviousStep_NextStep'. The duplicate key value is (96, 1, 2).