I have a table in this form:
id | firstname | lastname
---+-----------+----------
1 | alex | marti
2 | mark | finger
3 | alex | marti
4 | ted
--Remove Duplicate Rows with different ID SQL SERVER
CREATE TABLE #TempTable
(
Id int,
Firstname varchar(20),
Lastname varchar(20)
)
INSERT INTO #TempTable( Id, Firstname, Lastname) SELECT min(Id)as Id, Firstname, Lastname
FROM UserTable
GROUP BY Firstname, Lastname
delete from UserTable where Id not in(select Id from #TempTable)
drop #TempTable