Sql Server Interview Questions and Answers (1758) - Page 35

Which of the following queries that use string functions will return the result 'aus'?

NOTE: This is objective type question, Please click question title for correct answer.
Which of the following mathematical functions would you use to calculate the absolute numeric value of a numeric value?

NOTE: This is objective type question, Please click question title for correct answer.
Which of the following statements would you use to mark the start point of an explicit local transaction?

NOTE: This is objective type question, Please click question title for correct answer.
Write a SQL Query to find the second maximum salary without using TOP keyword. Consider the following Employee table EmpID Salary 1 1000 2 2000 3 5200 4 7855 5 4000 6 6500 7 7000

Here the main constraint is we should not use the TOP keyword.

The query is

select MAX(Salary) from tbl_Employee

where Salary <> (
select MAX(Salary) from tbl_Employee)


In sub query I am first getting the Maximum salary of Employee Table. Now 7855 will come. In the outer query I am using Where condition to check the salary NOT EQUAL to 7855 and gettting the maximum value in select query. So now the query will be
select MAX(Salary) from tbl_Employee

where Salary <> 7855


The above query gives 7000 which is the second maximum salary
What is the difference between GetDate() and SysDateTime() in SQL Server 2008?

GetDate() and SysDateTime are used to fetch the current datetime of server. But there is a slight difference exists between these two. GetDate() used to get the time upto MilliSeconds where as SysDateTime used to get the time upto NanoSeconds.

If we run the query in Sql Server

SELECT GETDATE() [GetDate], SYSDATETIME() [SysDateTime]

The output will be

GetDate	                   SysDateTime

2012-12-03 11:28:43.500 2012-12-03 11:28:43.5004729

Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories