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 many columns can be used for creating index? : Sql dba
How to download oracle sql developer?
What is the difference between function, procedure and package in pl/sql?
What is trigger in flip flop?
how many ways to get the current time? : Sql dba
What are hotfixes and patches?
What is procedure explain with example?
What are properties of the transaction?
What is before trigger?
what is the syntax used for partition in tsql? : Transact sql
what is the difference between rownum pseudo column and row_number() function? : Sql dba
Show the two pl/sql cursor exceptions.
Why functions are used in sql?
What are few of the schema objects that are created using PL/SQL?
How can you fetch first 5 characters of the string?