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 create “dependant” parameter “make, model, year”
what is datawarehouse?
What do you understand by recursive stored procedures?
What is always encrypted?
What are the new security features added in sql server 2012? : sql server security
hi, how to link a text file and a .rpt file in my tables of sql server and to retrieve those records for further use. reply me as soon as possible.
What is query and its types?
How to create a Master database in SQL server ?
Create a dts package to produce a text file using the ‘update statistics’ command for the tables in a database with obsolete statistics.
sql database suspect We have a sql database that is showing as suspect. How can we recover?
Write a code to select distinct records without using the DISTINCT keyword.
Explain how long are locks retained within the repeatable_read and serializable isolation levels, during a read operation with row-level locking?
how can u get last observation in an unknown dataset ?
Tell me about the approaches which you used to counter the DI problems.
Beginning with sql server version 7 0, a new enhanced data type nchar was added what type of data is supported with this data type?