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
How to disable stored procedure sql server?
What are the differences between having and where clause.
What is a cursor, index in sql?
How to create a user to access a database in ms sql server using "create user" statements?
What is the difference between locking and multi-versioning?
What are the basic features of a trigger in ms sql server?
What is a trigger in sql server?
How to create an index on a view?
What is a result set object returned by odbc_exec()?
What to perform pattern match with the like operator?
Explain filtered indexes benefits?
Tell me what are cursors and when they are useful?
What are transactions and its controls?
Sql studio em braces a variety of capabilities, but will I need them all? Is there a simpler product ? : sql server management studio
What's the information that can be stored inside a bit column?