.Net Interview Questions and Answers

Search:

Various interview questions on SQL Server

By : Shiv Prasad Koirala | May 17th, 2014 | Views : 3927 | Comments : 0 Bookmark and Share

In this part we have tried to put some light on various SQL Server interview questions asked by the interviewer. So here we go with SQL Server questions.

 

What is primary key in SQL?

 

Primary key let us uniquely identify the row in a table.

 

How it is different from Unique key?

 

Primary key never accepts null value whereas in case of unique key one of the values can be null.

 

Can you write down a query which will display the current financial year?

 

Declare@CurrentDatedate='2014/1/16'

Declare@FinancialYearvarchar(100)=''

if(month(@CurrentDate)>3)

begin

       selectDatePart(yy,@CurrentDate),DatePart(yy,DateAdd(yy,+1,@CurrentDate))

end

else

begin

       selectDatePart(yy,DateAdd(yy,-1,@CurrentDate)),DatePart(yy,@CurrentDate)

end

 

How will you find the index of a particular character in a SQL variable?

 

We will use CharIndex method.

 

Let say we have multiple queries and we have to show result set of all queries as one result. What we have to do?

 

Use Union. 

 

Is it possible to use order by with UNION?

 

We cannot write order by in each query but can in last query which will affect entire result set.

 

Also see another SQL Server interview questions video on RowNumber, Partition, Rank & DenseRank : -

 

 
Rate this Article :
1 Star
2 Stars
3 Stars
4 Stars
5 Stars
1 1 1 2 1
 
 
 
 

.NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala

In this article we will explain .NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala.... Read More

What is the difference between Stored Procedures and Function (SQL Server interview question with answers)?

In this article we will explain what is the difference between Stored Procedures and Function.For more articles and videos visit us on www.questpond.com... Read More

Explain MVC application life cycle?

In this article we will explain MVC application life cycle.For more articles and videos visit us on www.questpond.com... Read More

C# Design pattern interview questions with answers: - How Singleton is different from Static class?

In this article we will explain How Singleton is different from Static class.... Read More

WCF interview questions and answers: - What is the difference between Service endpoint and Client endpoint?

In this article we will explain What is the difference between Service endpoint and Client endpoint.... Read More

.NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala

In this article we will explain .NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala.... Read More

What is the difference between Stored Procedures and Function (SQL Server interview question with answers)?

In this article we will explain what is the difference between Stored Procedures and Function.For more articles and videos visit us on www.questpond.com... Read More

Explain MVC application life cycle?

In this article we will explain MVC application life cycle.For more articles and videos visit us on www.questpond.com... Read More

C# Design pattern interview questions with answers: - How Singleton is different from Static class?

In this article we will explain How Singleton is different from Static class.... Read More

WCF interview questions and answers: - What is the difference between Service endpoint and Client endpoint?

In this article we will explain What is the difference between Service endpoint and Client endpoint.... Read More

Article Categories

Learn in Hindi