write a query to delete similar records in same table
Answer Posted / manjla
CREATE TABLE User_Details
(
UserID int ,
FName varchar (50),
MName varchar (50),
LName varchar (50),
Email varchar (50)
)
insert into User_Details values(1,'X','Y','Z','X@X.com')
insert into User_Details values(1,'X','Y','Z','X@X.com')
insert into User_Details values(2,'P','Q','R','P@P.com')
insert into User_Details values(3,'M','N','O','M@M.com')
insert into User_Details values(3,'M','N','O','M@M.com')
IF OBJECT_ID('tempdb..#TempTable') IS NOT NULL
DROP TABLE #TempTable
CREATE TABLE #TempTable
(
UserID int ,
FName varchar (50),
MName varchar (50),
LName varchar (50),
Email varchar (50)
)
go
INSERT INTO #TempTable SELECT DISTINCT * FROM User_Details
go
TRUNCATE TABLE User_Details
go
INSERT INTO User_Details SELECT * FROM #TempTable
SELECT * FROM User_Details
Is This Answer Correct ? | 5 Yes | 0 No |
Post New Answer View All Answers
how can we transpose a table using sql (changing rows to column or vice-versa) ? : Sql dba
what are the differences among rownum, rank and dense_rank? : Sql dba
Is it possible to link two groups inside a cross products after the cross products group has been created?
How do I remove sql plus from windows 10?
What is the difference between microsoft sql and mysql?
Why sql query is slow?
Why partition by is used in sql?
define data blocks ? : Sql dba
Can you have more than one key in a database?
Show the two pl/sql cursor exceptions.
Write the order of precedence for validation of a column in a table? I. Done using database triggers. Ii. Done using integarity constraints
How bulk collect improves performance?
What are the different dml commands in sql?
Why stored procedure is faster than query?
What does the argument [or replace] do?