adspace
Delete duplicate rows from a table without primary key by
using a single query
Table Employee
empname salary
A 200
B 300
A 200
C 400
D 500
D 500
Output should be
A 200
B 300
C 400
D 500
Answer Posted / samba shiva reddy . m
delclare @temp(empname varchar(50),sal int)
select * into @temp
FROM employee
GROUP BY empname, salary
HAVING count(*) > 1
delete from employee
select * into employee from @temp as temp
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
What is a view in sql?
What are different types of constraints?
How raid can influence database performance?
Where can you add custom error messages to sql server?
What are the different types of subquery?
What is sql or structured query language?
explain different types of backups avaialabe in sql server? Given a particular scenario, how would you go about choosing a backup plan? : Sql server database administration
What are the risks of storing a hibernate-managed object in a cache? How do you overcome the problems?
How to enter binary string literals in ms sql server?
What kind of problems occurs if we do not implement proper locking strategy?
How to convert numeric expression data types using the cast() function?
Can we make the the chages By Using the Sql if u know any function or process please inform me Actuall result: BRK1 Break 1 Part 1 00:01:00:00 60 BRK1 Break 1 Part 2 00:01:00:00 60 BRK2 Break 2 Part 1 00:01:00:00 60 BRK2 Break 2 Part 2 00:01:00:00 60 BRK2 Break 2 Part 3 00:01:00:00 60 BRK3 Break 3 Part 1 00:01:00:00 60 BRK3 Break 3 Part 2 00:01:00:00 60 Desired O/P: BRK1 Break 1 Part 1 00:01:00:00 60 Part 2 00:01:00:00 60 BRK2 Break 2 Part 1 00:01:00:00 60 Part 2 00:01:00:00 60 Part 3 00:01:00:00 60
Can we do dml on views?
What is the difference between upgrade and migration in sql server?
List the ways in which dynamic sql can be executed?