how to delete duplicate rows from table in sql server
Answer Posted / onlymoid
CREATE TABLE dbo.duplicateTest ------Deleting
Duplicates with same id
(
[ID] [int] ,
[FirstName] [varchar](25),
[LastName] [varchar](25)
) ON [PRIMARY]
INSERT INTO dbo.duplicateTest VALUES(1, 'Bob','Smith')
INSERT INTO dbo.duplicateTest VALUES(2, 'Dave','Jones')
INSERT INTO dbo.duplicateTest VALUES(3, 'Karen','White')
INSERT INTO dbo.duplicateTest VALUES(1, 'Bob','Smith')
SELECT * FROM dbo.duplicateTest
SET ROWCOUNT 1
DELETE FROM dbo.duplicateTest WHERE ID = 1
SET ROWCOUNT 0
SELECT * FROM dbo.duplicateTest
Drop table dbo.duplicatetest
| Is This Answer Correct ? | 5 Yes | 2 No |
Post New Answer View All Answers
What are the differences between sql server and mysql.
how can you find out if the current user is a member of the specified microsoft® windows nt® group or microsoft sql server™ role? : Sql server administration
What is the difference between writing data to mirrored drives versus raid5 drives
How to test a dml trigger in ms sql server?
What does REVERT do in SQL Server 2005?
How is sql used in sql server?
What is store procedure? When do you use?
What are the advantages of sql azure?
Explain differentiate between a having clause and a where clause?
Explain what is it unwise to create wide clustered index keys?
How to generate create view script on an existing view?
What are sub reports?
How to skip remaining statements in a loop block using continue statements?
Explain following error properties?
Is profiler the only tool that has the ability to audit and identify ddl events? : sql server security