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 do I find the port number for sql server?
What are four major operators that can be used to combine conditions on a where clause?
Which sql server table is used to hold the stored procedure script?
Explain what is row_number function?
What is sql language?
What is Dependency Injection and provide example?
How to insert data with null values?
Mention what are the different types of ssrs reports?
How to get the definition of a user defined function back?
How to delete duplicate rows from table except one?
How do you handle datasets larger than 50 gb?
How to receive returning result from a query?
What is ms sql server triggers?
Are there issues when exporting SSRS reports into Microsoft Excel? When my users are trying to export a SSRS report into Microsoft Excel, one or two columns in the report appear to merge together. Why might this be?
What are the steps to follow to configure SQL*Net?