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
we have emp table like Ename,EDOJ,EDOB with Column 
structure.but we want to know the employee Age.How? Any 
Body Plz
 Question Submitted By :: Reddy
I also faced this Question!!     Rank Answer Posted By  
 
  Re: we have emp table like Ename,EDOJ,EDOB with Column structure.but we want to know the employee Age.How? Any Body Plz
Answer
# 1
Hi,
In order to  answer your question I would like to put all 
three possible answers as follows:-

1.If You want to find out the age of employee as on the 
date of Joining (Field name EDOJ) then Query will be

select *,datediff(year,EDOB,EDOJ) as Eage from emp

2. If you want to find out the age of employees as on 
current date, query will be as follows:-
 
select *,datediff(year,EDOB,getdate()) from emp

3. If you want to find out age as on specific date stored 
and taken from other variable then query will be :-

You need to declare a variable as datetime then need to 
tore its value to it.

declare @dtb datetime
set @dtb='1990/01/10'
select *,datediff(year,EDOB,@dtb) from emp
---------------------------------------
For any clarification Please feel free to contact me.
Rajesh
9342284359
 
Is This Answer Correct ?    0 Yes 0 No
Rajesh K. Gupta
 
  Re: we have emp table like Ename,EDOJ,EDOB with Column structure.but we want to know the employee Age.How? Any Body Plz
Answer
# 2
Thanks Rajesh K. Gupta.
 
Is This Answer Correct ?    0 Yes 0 No
Reddy
 
 
 
  Re: we have emp table like Ename,EDOJ,EDOB with Column structure.but we want to know the employee Age.How? Any Body Plz
Answer
# 3
select trunc(months_between(Sysdate,EDOB)/12)Age from emp;
 
Is This Answer Correct ?    0 Yes 0 No
Santhi K
 
  Re: we have emp table like Ename,EDOJ,EDOB with Column structure.but we want to know the employee Age.How? Any Body Plz
Answer
# 4
The answer submitted by Santhi K is wrong, Can shanti test 
this query in sql server, because i ran it it does not 
accept. there is no such months_between function
 
Is This Answer Correct ?    0 Yes 0 No
Rajesh K. Gupta
 
  Re: we have emp table like Ename,EDOJ,EDOB with Column structure.but we want to know the employee Age.How? Any Body Plz
Answer
# 5
Answer i submitted is for Oracle not for SQL server.
Sorry!
Plz always mention the RDBMS which you are using ,in the 
post.
Bcoz,This Oracle query may not work in other RDBMS.
 
Is This Answer Correct ?    0 Yes 0 No
Santhi K
 
  Re: we have emp table like Ename,EDOJ,EDOB with Column structure.but we want to know the employee Age.How? Any Body Plz
Answer
# 6
FOR SQL 2005:

select datediff (day, birthdate, getdate())/365 from emp
 
Is This Answer Correct ?    0 Yes 0 No
Monal
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
Which TCP/IP port does SQL Server run on?  2
What is the difference between temp table and table variable? Microsoft3
What are Magic Table? Evalueserve10
Which system table contains information on constraints on all the tables created?  2
what is the order of execution of where,having,group by in select stement Tanla-Solutions4
What is the difference Between Sql-server 2000 & 2005 Value-Labs1
WHY CAN WE CREATE ONLY ONE CLUSTERED INDEX ON A TABLE IN SQL SERVER?  5
How will oyu test the stored procedure taking two parameters namely first name and last name returning full name?  3
What are the types of backup and tell me the difference between full and differential backup? TCS3
How do SQL server 2000 and XML linked?  1
how to retrive only second row from table in sql server 2000? CTS7
What is a deadlock and what is a live lock? How will you go about resolving deadlocks?  1
i want to join two queries....and i want to run them as one after another that is want output of first query then second , then again output of first query then second and so on...  1
Is it possible to delete duplicate rows in a table without using a temporary table ?  5
What is a NOLOCK?  3
can you any body tell me the difference between candidate key and primary key  2
what is diffence between replicaion and logshipping?  1
Different Types of Functions ? Satyam2
Difference between Triggers and Stored Procedure Protech7
plz tell me the new features of sqlserver2000,sqlserver2002,sqlserver2005  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