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
Does the unique constraint create an index?
Explain how does the report manager work in ssrs?
How to locate and take substrings with charindex() and substring() functions?
Describe in brief authentication modes in sql server.
What command would you use to create an index?
What are the differences between char and nchar in ms sql server?
What is inner join in sql server joins?
How to create user defined functions with parameters?
Tell me about joins in database system and explain each in detail.
What is filter index?
How to create user messages with print statements in ms sql server?
When does a workload on SQL Azure get throttled?
What are the types of resultset?
Are all views updatable ?
What is the maximum size of a dimension? : sql server analysis services, ssas