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
what are the join types in tsql? : Transact sql
What is exception? What are the types of exceptions?
What is primary and foreign key?
how to use myisamchk to check or repair myisam tables? : Sql dba
What are dml commands?
What are sql triggers used for?
How exception handling is done in advance pl/sql?
What are the rules to be applied to nulls whilst doing comparisons?
what are the non-standard sql commands supported by 'mysql'? : Sql dba
What is the use of & in pl sql?
How do you remove duplicate records from a table?
what are the advantages of using stored procedures? : Sql dba
Can we perform dml on view?
Why is pl sql needed?
Show the cursor attributes of pl/sql.