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                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
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 ?    4 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 ?    1 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 ?    1 Yes 0 No
Monal
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
What is a trigger?  6
What is lock escalation?  1
Alternative way to DetDate() function?  4
Questions on identity? Infosys1
What are cursors? Name four types of cursors and when each one would be applied? Adea-Solutions1
internal language used in sql server 2000?  1
to explain sql server 2000 architecture & authentication  1
What is a Trace frag?Where can we use this?  1
What is Files and Filegroups in SQL Server & it's implementation. Zenith1
what is IDE,DMV in sql server? Value-Labs1
How to select nth record from a table? DELL9
how do u do Performance tunning ? Satyam1
Lets say due to N/W or Security issues client is not able to connect to server or vice versa. How do you troubleshoot?  1
Can a stored procedure call another stored procedure. If yes what level and can it be controlled?  2
what is bit data type? and what are the information that can be stored inside a bit column?  2
Let’s say the table in the database is named as TBL_Register. The fields in this table include: 1. User_Name, 2. User_Telephone, 3. Register_Date The field Register_Date stores the current date and time of the registration. Write the SQL statement that inserts the data into the table. Techno-Solutions2
Can I know,how to Execute Funcion and Trigger through command(Manualy Execution) in MS SQL/SERVER 2005,give me answer with Example.  1
Which TCP/IP port does SQL Server run on?  2
1. What are the grouping function in SQL ? 2. If base table of a view deleted means, what will happen while we querying on view ? will give any error ? 3. Difference between DROP, DELETE, TRUNCATE table ? 4. What is constraints and types ? 5. What is max size of nchar & nvarchar ? 6. Define ROLLBACK, COMMIT, SAVE POINT 7. How non-clustered better ? or rank the Clustered, Non-Clustered and Table scan in performance wise 8. Select 10 rows from a table ? 9. Define DML, DDL, DCL, DTL commands ? 10. What is mean by NULL value ? NULL means "" or 0 or undefined ? 11. Default constraints ? 12. Can we have more then primary Key in table ? 13. Type of integrity ? Entity, Referential, Domain ? Perot-Systems8
Difference between server.transfer and server.execute method?  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