SQL Server Interview Questions

SQL Server Interview Questions

Below are the list of common SQL Server Interview Questions, that generally candidate faces in their IT company Interviews.

In this blog post various aspect of the interview questions and answers are posted. I tried to cover the practical approach which sql statements the you can try and run on your database to make it more clear.

So lets have a look on these questions and answers.

How to find third or nth maximum salary from salary table

SELECT Salary,EmpName
SELECT Salary,EmpName,ROW_NUMBER() OVER(ORDER BY Salary) As RowNum
) As A
WHERE A.RowNum IN (2,3)

Delete duplicate rows Sql Server

Take a look in the following table content. Its having duplicate rows.

Id       Name           Department

1        Deepak               .NET

2        Jitendra             .NET

3        Annu                   php

4        Deepak               .NET

5        Yogesh                 Graphics

Row 1 and 4 are duplicate. So we have to remove one row and keep one in the table.

Now question is how to do?

WITH tblTemp as
   As RowNumber,* FROM <table_name>
DELETE FROM tblTemp where RowNumber >1


Write down the query to print first letter of a Name in Upper Case and all other letter in Lower Case.(EmployDetail table)

 SELECT UPPER(SUBSTRING(FirstName,1,1))+LOWER(SUBSTRING(FirstName,2,LEN(FirstName)-1)) AS [FirstName]

Deepak Arora

Deepak Arora is a Software Developer and working continuously in this field from 2011. He work mainly with Microsoft Technology. He holds a Master's in Computer Application and he is MCTS certified person.

Leave a Reply

Your email address will not be published. Required fields are marked *