New answers tagged duplication
SELECT * FROM foos INNER JOIN ( SELECT name FROM foos GROUP BY name HAVING COUNT(*) > 1 ) AS dup ON foos.name = dup.name ORDER BY name
Assuming the following table definition CREATE TABLE T ( Name VARCHAR(50) NOT NULL, IsDeleted BIT NOT NULL ) Then you can achieve this with a unique index filtered to only include those Names that you wish to apply the constraint on. CREATE UNIQUE INDEX ix ON T(Name) WHERE IsDeleted = 'false'
Top 50 recent answers are included