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
Explain acid?
What is difference between aggregate and analytic function?
Explain the use of containers in ssis and also their types?
How to convert binary strings into integers in ms sql server?
Define magic tables in sql server?
Is it possible to replicate data from sql server to oracle? : sql server replication
What is TDS(Tabular Data Stream) Gateway?
Different types of keys in SQL?
Can you pass expressions to function parameters?
What is truncate table?
How to insert new line characters into strings?
Does table partitioning improve performance?
Difference between connected and disconnected database in .net with sql server?
can an automatic recovery be initiated by a user? : Sql server administration
How to use go command in "sqlcmd"?