SQL Server interview question - What is the use coalesce in SQL Server?
- By Shiv Prasad Koirala in SQL
- Dec 4th, 2012
- 1674
- 0
This is simple SQL Server interview question and answer is simple.It's just that many developers have not heard it so it some time becomes confusing the answer same.
Coalesce return the first non-null column from more than one columns. For instance you can see in the below table either "First Name" has null values "Surname" as null value. Now you would like to pull values using coalesce function and it will return the column which will have null values.
![]()
So if you fire the below SQL statement with coalesce.
So when:-
- If "Surname" is null and "FirstName" is not null,then "FirstName" is returned.
- If "FirstName" is null and "SurName" is not null,then "SurName" will be returned.
Below is the output/

Here's simple list of Six important SQL Server interview question with answers,do have look at the same.
This question is taken from Chapter 3 SQL chapter from the 300 pages book SQL Server interview questions and answers. You can also see our blog which is exclusive for SQL Server interviews.
You can also see our blog which isexclusive for SQL Server interviews.
Shiv Prasad Koirala
Visit us @ www.questpond.com or call us at 022-66752917... read more
- By Shiv Prasad Koirala
- Jan 17th, 2012
- 13423
- 0
.NET interview questions: - Can you elaborate project life cycle?
- By Shiv Prasad Koirala
- Aug 3rd, 2011
- 10192
- 0
Five most important SharePoint 2010 interview questions
- By Shiv Prasad Koirala
- Nov 16th, 2011
- 9918
- 0

