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                      
tip   SiteMap shows list of All Categories in this site.
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
How to delete duplicate records from a table?(for suppose in
a table we have 1000 Records in that we have 200 duplicate
Records , so ,how to findout that duplicate Records , how to
delete those Records and arranged into sequence order? one
more thing that  there is no primary key at all)
 Question Submitted By :: Katha.net
I also faced this Question!!     Rank Answer Posted By  
 
  Re: How to delete duplicate records from a table?(for suppose in a table we have 1000 Records in that we have 200 duplicate Records , so ,how to findout that duplicate Records , how to delete those Records and arranged into sequence order? one more thing that there is no primary key at all)
Answer
# 1
We will get the duplicate records and insert them into a 
new temp table by using below query:

select * into tmp_Employee
from Employee
having count(distinct *) > 1

Now delete the duplicate records from Employee table:

delete from Employee
having count(distinct *) > 1

Now insert the records from tmp_Employee to Employee table:

insert into Employee
select * from tmp_employee

drop table tmp_employee
 
Is This Answer Correct ?    3 Yes 8 No
Pooja Narang
 
  Re: How to delete duplicate records from a table?(for suppose in a table we have 1000 Records in that we have 200 duplicate Records , so ,how to findout that duplicate Records , how to delete those Records and arranged into sequence order? one more thing that there is no primary key at all)
Answer
# 2
with numbered as(select rowno = row_number() over(partition 
by empid order by empid),empname from employee)delete from 
numbered where rowno > 1
 
Is This Answer Correct ?    0 Yes 2 No
Sirisha
 
 
 
  Re: How to delete duplicate records from a table?(for suppose in a table we have 1000 Records in that we have 200 duplicate Records , so ,how to findout that duplicate Records , how to delete those Records and arranged into sequence order? one more thing that there is no primary key at all)
Answer
# 3
select distinct * from table into new_table;

delete table;

select * from new_table into table;
 
Is This Answer Correct ?    4 Yes 0 No
Sneha
 
  Re: How to delete duplicate records from a table?(for suppose in a table we have 1000 Records in that we have 200 duplicate Records , so ,how to findout that duplicate Records , how to delete those Records and arranged into sequence order? one more thing that there is no primary key at all)
Answer
# 4
;with empctc(empid,ename,sal,deptid,ranking)
as
(Select empid,ename,sal,deptid,ranking=Dense_rank() over (
partition by empid,ename,sal,deptid order by NEWID() asc) 
from emp
)
delete * from empctc where ranking>1
 
Is This Answer Correct ?    0 Yes 1 No
Smitha
 
  Re: How to delete duplicate records from a table?(for suppose in a table we have 1000 Records in that we have 200 duplicate Records , so ,how to findout that duplicate Records , how to delete those Records and arranged into sequence order? one more thing that there is no primary key at all)
Answer
# 5
DELETE FROM emp WHERE ROWID NOT IN(SELECT MAX(ROWID) FROM 
emp GROUP  BY empno)
 
Is This Answer Correct ?    0 Yes 0 No
Cp
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
how to copy sysdatabase file from c: Drive to D: Drive in SQL Server. IBM4
What is the difference between UNION and UNIONALL? CTS2
What about UPDATESTATISTICS ? Intelligroup2
What are constraints? Explain different types of constraints?  6
select the 3rd maximum salary from sql server database if 4 (just an example In practically I may not know the exact situation) of the highest salaries are equal.  7
From where can you change the default port?  3
i have table students with fields classname,studname select * from students classname studname 1 xxxxx 1 yyyy 1 zzzz 2 qqqq 2 tttt 3 dsds 3 www i want the output should be No of students in class 1 : 3 No of students in class 2 : 2 No of students in class 3 : 2 HCL2
I have a table in which phno is one of the columns.i do have some values in tht phno column.i need to update phno column values with 0(zero) as prefix.give me a correct solution plz... Value-Labs5
Can anybody explain me cold backup and hot backup? TCS3
What is a Linked Server?  1
what is the Surrogate key?and wt is the diff between Primary key and Surrogate Key?  2
what is the maximum size of a row in sql server 2000 and 2005  2
1.what is stored procedure?Its significance with example? 2.Explain about index with syntax and example? plz do reply.........  1
What is an extended stored procedure? Can you instantiate a COM object by using T-SQL?  1
Please get the 4 th maximum salary from a table without using any sql keyword (TOP,MAX are mot allowed)  5
What is referential integrity and how is it achieved? Adea-Solutions1
What is the difference between two queries: 1. SELECT * FROM table WHERE 1=1; 2. SELECT * FROM table HP15
What is the datatype returned by count(*) Asian-CERC18
write down the code for "how we delete a table without using of Drop command " ? Sonata2
which query u can write to sql server doesn't work inbetween 7.00PM to nextday 9.00AM Wipro4
 
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