ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Software  >>  Databases  >>  SQL Server
 
 


 

 
 Oracle interview questions  Oracle Interview Questions
 SQL Server interview questions  SQL Server Interview Questions
 MS Access interview questions  MS Access Interview Questions
 MySQL interview questions  MySQL Interview Questions
 Postgre interview questions  Postgre Interview Questions
 Sybase interview questions  Sybase Interview Questions
 DB Architecture interview questions  DB Architecture Interview Questions
 DB Administration interview questions  DB Administration Interview Questions
 DB Development interview questions  DB Development Interview Questions
 SQL PLSQL interview questions  SQL PLSQL Interview Questions
 Databases AllOther interview questions  Databases AllOther Interview Questions
Question
Is it possible to delete duplicate rows in a table without 
using a temporary table ?
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Is it possible to delete duplicate rows in a table without using a temporary table ?
Answer
# 1
Yes, it is possible by using in memory table variables on 
SQL server 2000 and above.

A table variable can be created and all disticnt values can 
be inserted into this table and then deleting all rows from 
first table you can insert back disticnt rows to back to 
original table. Table variable would automatically be 
destroyed whenever bacth execution finishes.

 
Is This Answer Correct ?    3 Yes 1 No
Ambuj Tayal
 
  Re: Is it possible to delete duplicate rows in a table without using a temporary table ?
Answer
# 2
using cursor is another option
 
Is This Answer Correct ?    0 Yes 1 No
Ghous
 
 
 
  Re: Is it possible to delete duplicate rows in a table without using a temporary table ?
Answer
# 3
sno         names 
1           arun
2           arun
3           arun
6           arun
7           bala
11          bala
12          guna
9           guna
14          guna
10          raj
13          raj

Table Name T1
Fields Names Sno,Names
Delete From t1 where sno not in 
(select min(sno) from t1 group by names)
 
Is This Answer Correct ?    9 Yes 3 No
Kumar
 
  Re: Is it possible to delete duplicate rows in a table without using a temporary table ?
Answer
# 4
Jaare Kameeney
 
Is This Answer Correct ?    2 Yes 6 No
Hakoona
 
  Re: Is it possible to delete duplicate rows in a table without using a temporary table ?
Answer
# 5
select * into #empnew from (select * from emp union select 
* from emp) a
 
Is This Answer Correct ?    1 Yes 4 No
Saravanan
 
  Re: Is it possible to delete duplicate rows in a table without using a temporary table ?
Answer
# 6
yes its very much possible.
create table #student
(name varchar(10),age integer)

insert into #student values ('A',12)
go 2
insert into #student values ('B',13)
go 3
insert into #student values ('C',15)
go 4
insert into #student values ('D',14)
go 5


SET ROWCOUNT 1
DELETE #student FROM #student A WHERE (SELECT COUNT(*) FROM 
#student B WHERE A.NAME = B.NAME AND A.AGE = B.AGE) > 1
WHILE @@ROWCOUNT > 0
DELETE #student FROM #student A WHERE (SELECT COUNT(*) FROM 
#student B WHERE A.NAME = B.NAME AND A.AGE = B.AGE) > 1
SET ROWCOUNT 0
 
Is This Answer Correct ?    1 Yes 0 No
Balaji
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
The Difference between 'Count' and 'Count(*)'  12
Can a stored procedure call another stored procedure. If yes what level and can it be controlled?  2
when we use function instead of procedure? plz tell me the situation with ex?  1
What are Magic Table? Evalueserve15
Questions on identity? Infosys1
Difference between server.transfer and server.execute method?  1
how insert selected column only ? Robert-Half2
WHY CAN WE CREATE ONLY ONE CLUSTERED INDEX ON A TABLE IN SQL SERVER?  6
What are the different types of replication? How are they used?  3
what are file groups? Evalueserve3
What is lock escalation?  1
How m-m relationships are implemented?  1
What is the appropriate number of test cases that you can write on a database? Microsoft1
how to find number of columns in a table in sql server 2000 and 2005 also Virtusa7
How do you persist objects, permissions in tempdb  1
one table has four field id,name,design,salary. i have to find maximum salary .  6
What are cursors?  8
Is it possible to have more then one foreign key in a single table? if possible, is this the good way to design the table?  2
About Indexed Views? with example? plz reply...  2
Write a query to delete duplicate records in SQL SERVER Infosys19
 
For more SQL Server Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com