adspace


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 / vikas kant

select Distinct * into #Temp_Temp1 from Emp
truncate table Emp
insert into Emp select * from #Temp_Temp1
select * from Emp

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How raid can influence database performance?

1116


What is sql or structured query language?

1226


This question asked during interview, 2) At the end of each month, a new table is created for each bank that contains monthly metrics consolidated at the account level. The table naming convention is bankX_YYYYMM where X represents the numeric designation of the bank and YYYYMM indicates the 4 digit year and 2 digit month. The tables contain the following fields: name data type description account text account number registered boolean indicates whether the account is registered num_trans integer number of transactions made during the time period spend numeric(9,2) total spend during the time period a) Write a SQL query that will display the total number of transactions and total spend for "Bank1" during the 4th quarter of 2009. b) Write a SQL query that will display the total number of transactions and total spend at "Bank1" and "Bank2", broken out by registered vs. non-registered accounts, during January 2010 not sure what is correct answer and how to solve?

2565


Equi join and non equi join is possible with sql server?

1134


What is the difference between upgrade and migration in sql server?

1183


Why and when do stored procedure recompile?

1056


How do I find query history in sql server?

1022


List the ways in which dynamic sql can be executed?

1085


What kind of problems occurs if we do not implement proper locking strategy?

1499


How to connect php with different port numbers?

1186


Can we do dml on views?

1036


How can we solve concurrency problems?

1121


What is the difference between for xml raw and for xml auto?

1114


Is it possible to have clustered index on separate drive from original table location?

1039


Can sql servers link to other servers like oracle?

915