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
in tabase table having a column in it empname field is 
there which having 5 duplicate values is there i want 
deleted all the duplicates i want showing only one name 
only.
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: in tabase table having a column in it empname field is there which having 5 duplicate values is there i want deleted all the duplicates i want showing only one name only.
Answer
# 1
we can use cursor.
 
Is This Answer Correct ?    0 Yes 0 No
Ambarish
 
  Re: in tabase table having a column in it empname field is there which having 5 duplicate values is there i want deleted all the duplicates i want showing only one name only.
Answer
# 2
Hope this methodology would help you better

1.Create a temp table
2.Select duplicated row's empid,empname into the temp table.
3.Create a cursor by selecting values from temp table.
4.Keep either min or max(empid) from original table and 
delete the rest of the duplicated rows.
 
Is This Answer Correct ?    0 Yes 0 No
Venkat
 
 
 
  Re: in tabase table having a column in it empname field is there which having 5 duplicate values is there i want deleted all the duplicates i want showing only one name only.
Answer
# 3
Table structure :-

empid   empname
1       bala
2       bala
3       bala
4       bala
5       arun
6       arun
7       arun       
8       ram
9       ram

Delete from employee where empid 
not in (Select min(empid) from employee group by emp
having count(empid)>1)

By
Kumar
 
Is This Answer Correct ?    1 Yes 0 No
Kumar
 
  Re: in tabase table having a column in it empname field is there which having 5 duplicate values is there i want deleted all the duplicates i want showing only one name only.
Answer
# 4
Kumar your query do not solve the purpose accurately.

It should be as

Delete from employee where empid 
not in (Select min(empid) from employee group by empname
having count(empname)>=1)
 
Is This Answer Correct ?    0 Yes 1 No
Dinesh Gupta
 
  Re: in tabase table having a column in it empname field is there which having 5 duplicate values is there i want deleted all the duplicates i want showing only one name only.
Answer
# 5
use distinct commond

distinct(ename) from table name
 
Is This Answer Correct ?    0 Yes 1 No
Dinesh Gupta
 
  Re: in tabase table having a column in it empname field is there which having 5 duplicate values is there i want deleted all the duplicates i want showing only one name only.
Answer
# 6
WITH DUPLICATE(EmpName, RowNumber)
AS
(SELECT EmpName,ROW_NUMBER() OVER (PARTITION BY EmpName 
order by EmpName) AS RowNumber
FROM Employee)

DELETE FROM DUPLICATE WHERE RowNumber > 1

------------------------------------------------------------
Using CTE (Common Table Expressions) and ROW_NUMBER as 
ranking fucntion 


Jiri JANECEK
MSE, MBA, MCSD.NET
 
Is This Answer Correct ?    1 Yes 0 No
Jiri
 
  Re: in tabase table having a column in it empname field is there which having 5 duplicate values is there i want deleted all the duplicates i want showing only one name only.
Answer
# 7
delete from emp where empid not in(select max(empid) from 
emp group by empname having count(*)>=1)
 
Is This Answer Correct ?    1 Yes 0 No
Karna
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
what are the new features of sql server 2005? HP5
What are user defined datatypes and when you should go for them?  1
What is cursor ? And what is difference between Trigger ? HCL1
Can you explain the role of each service?  1
What is BCP? When do we use it?  1
what is cluster and nin-cluster index?  4
Can you have a nested transaction? HCL3
What is normalization and what are the different forms of normalizations?  1
WHY CAN WE CREATE ONLY ONE CLUSTERED INDEX ON A TABLE IN SQL SERVER?  6
any one can explain Self mapping Delegation Remote Credentials  1
Explain the basic concepts of SQL server architecture?  2
what is the Surrogate key?and wt is the diff between Primary key and Surrogate Key?  2
9. Write a query to list a new column with the difference in temp of the cities Delhi and Mumbai, Mumbai and Jammu and soon. Consider the following table : City_id City Temp. 1 delhi 40 2 Mumbai 35 3 Jammu 32 4 Pune 18  2
which database is best to use in oracle and sql server? explain reasons? TCS5
How To Make password Protected SQL Server 2005 Database i.e when i open SQL Server database then ask for password.  1
What is MSDE?  2
What is user stored procedure & it purpose? Wipro3
What are the two types of concurrency?  2
hi i gone though satyam interview. what is Acid Properties? Satyam2
What is INTVAL( )and where we use Plz any body help me  1
 
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