I have a table with nearly-duplicate rows. I'm trying to get rid of the nearly duplicates. By nearly-duplicates, I mean that all of the columns except one have the same values.Here's my table:CREATE TABLE [dbo].[ActiveDirectory_Export]( [givenName] [nvarchar](255) NULL, [surname] [nvarchar](255) NULL, [samAccountName] [nvarchar](255) NULL, [notesShortName] [nvarchar](255) NULL, [employeeID] [nvarchar](255) NULL) ON [PRIMARY]
A person can have more than one samAccountName for which all other values are the same. E.g. givenName surname samAccountName notesShortName employeeIDBob Smith ARZ1011 BSmith 1001Bob Smith ARZ1011ep BSmith 1001Lisa Smith FQYS4277 LSmith 2304Lisa Smith FQYS4277ep LSmith 2304Lisa Smith FQYS4277sup LSmith 2304
Sorted alphabetically on notesShortName then samAccountName, I want to retain the first row for each user and delete the rest.I've been at this for over an hour and I'm stumped. How can I do this?