如果表中有ID
SELECT * FROM dbo.tblMainUser WHERE ID NOT IN (SELECT MAX(ID) FROM tblMainUser GROUP BY UserName,pwd)
如果表中没有自增ID
SELECT IDENTITY(INT,1,1) AS id,* INTO #temp FROM TblTest1 SELECT *FROM #temp WHERE id in( SELECT MAX(id)FROM #temp GROUP BY UserName,Pwd HAVING count(*)>1 )