Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8358903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:57:28+00:00 2026-06-09T10:57:28+00:00

I am working on a Microsoft SQL Server 2005 with Transact-SQL. I am trying

  • 0

I am working on a Microsoft SQL Server 2005 with Transact-SQL.

I am trying to concatenate string values coming from different columns of the same table dealing with NULL values.

Say for example the table is Person and the columns are FirstName, SurnamePrefix, LegalSurname

It happened that concatenating a string value with a NULL value (coming from two different columns) returns in output a NULL value.
I tried different scenarios to prevent NULL values in output:

  • Starting from:
    • Person.FirstName + ' ' + COALESCE(RTRIM(LTRIM(Person.SurnamePrefix)) + ' ', '') + Person.LegalSurname
  • I changed my statement to:
    • COALESCE(Person.FirstName + ' ', '') + COALESCE(Person.SurnamePrefix, '') + COALESCE(' ' + Person.LegalSurname, '')

Then I came across functions like ISNULL(), NULLIF() etc.

Which is the best and efficient approach to show empty strings values in output rather than NULL values?
Is the solution affected by the version of the SQL Server? (i.e. 2005, 2008, etc.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T10:57:29+00:00Added an answer on June 9, 2026 at 10:57 am

    ISNULL is good for default values, as you are doing. COALESCE has the advantage of accepting more than two arguments. NULLIF is quite different as it returns a NULL if the arguments are equal.

    You can benchmark them for performance. I suspect that the difference is negligible and that it is far more important to opt for clarity in your code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with Microsoft SQL Server 2005, and when I execute this query:
I'm working in Microsoft SQL Server 2005 and need to do an analysis of
I'm working in Microsoft SQL Server Management Studio CLR registering .dlls into the database
I've got the following T-SQL code below that's working from inside of SQL Server
I am doing some research on migrating away from Microsoft sql server to postgresql
I am developing one web application using asp.net 2005 and Microsoft SQL Server 2008
Working with Microsoft SQL Server I found extremely useful SQL Server Profiler and Estimated
I am working with a database hosted at GoDaddy using Microsoft SQL Server Management
I am using Microsoft SQL Server I am trying to use the following sql
Recently I have been working with a SQL Server database and I was trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.