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 is the maximum size of a dimension? : sql server analysis services, ssas
there is a trigger defined for insert operations on a table, in an oltp system. The trigger is written to instantiate a com object and pass the newly inserted rows to it for some custom processing. What do you think of this implementation? Can this be implemented better? : Sql server database administration
How to delete duplicate records based on single column from a table?
How many types of attribute relationships are there? : sql server analysis services, ssas
What is temporary table in sql server? Why we use temp table?
How many types of cursor type are there?
What stored by the msdb? : sql server database administration
What kind of problems occurs if we do not implement proper locking strategy?
What is ms sql server reporting services?
What is built-in/administrator?
How to select some specific rows from a table in ms sql server?
What is exclusive locks?
Can we use custom code in ssrs?
What are character string data types in ms sql server?
difference between Clustered index and non clustered index ?