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

Does the unique constraint create an index?

740


Explain how does the report manager work in ssrs?

703


How to locate and take substrings with charindex() and substring() functions?

697


Describe in brief authentication modes in sql server.

729


What command would you use to create an index?

775






What are the differences between char and nchar in ms sql server?

716


What is inner join in sql server joins?

704


How to create user defined functions with parameters?

838


Tell me about joins in database system and explain each in detail.

800


What is filter index?

698


How to create user messages with print statements in ms sql server?

759


When does a workload on SQL Azure get throttled?

127


What are the types of resultset?

708


Are all views updatable ?

892


What is the maximum size of a dimension? : sql server analysis services, ssas

763