I have a table EMP in which the values will be like this

EmpId Ename Sal DeptId
11 Ram 10000 10
11 Ram 10000 10
22 Raj 20000 20
22 Raj 20000 20
33 Anil 15000 30
33 Anil 15000 30

I want to delete only duplicate Rows. After Delete I want
the output like this

EmpId Ename Sal DeptId
11 Ram 10000 10
22 Raj 20000 20
33 Anil 15000 30



Answer Posted / kishor kumar

This can be solved by 2 Ways

One way

Create unique index on this Table with ignore duplicate row

2nd way.

1st transfer the data to a temp table bu using Distinct
clause then truncate the EMP table and then transfor the
data from temp table to EMP Table.

select distinct (column names) in to #temp from EMP

Truncate table EMP

INSERT INTO EMP

SELECT * FROM #temp

Is This Answer Correct ?    9 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a program to fetch first 10 records from a file?

607


How to use clusters?

555


Explain triggers?

565


What command is used to rename the database?

531


Explain an automatic checkpoint

566






What is statement level trigger?

545


Tell me what is the order in which the sql query is executed?

533


How to Update from select query in sql server?

550


What program is used to store the data source file?

508


Mention the differences between substr and charindex in sql server.

525


Explain multiserver query

559


What are the advantages of using stored procedures in sql server?

512


Explain the properties of sub-query in sql server?

514


How to connect of datebase with sql express.?

628


What are constraints?

592