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 7049559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:01:55+00:00 2026-05-28T03:01:55+00:00

I posted a similar question a while back and now as I need to

  • 0

I posted a similar question a while back and now as I need to update this code, I am back to ask a follow-on question. Previous question is here:
Computed column based on nullable columns

My data (Address1, Address2, City, State, Zip, Country) may have incomplete information. I.e. I can’t be guaranteed that anything other than State and Country columns will have data.

I would like to have a computed columns for FullAddress.

Previously, I used COALESCE, which worked great if all fields are filled in. Now, as the data requirements have been relaxed, this is no longer an option (because we end with repeated commas in the FullAddress). Here is what I have been using previously (note, I’m just working with SELECT statements here for ease of use – will convert into a computed columns “alter table add” statement once I have something that works for all cases):

SELECT (((((COALESCE([Address1],'')
    + COALESCE(', '+[Address2],''))
    + COALESCE(', '+[City],''))
    + COALESCE(', '+[State],''))
    + COALESCE(', '+[Zip],''))
    + COALESCE(', '+[Country],'')) AS FullAddress
FROM Locations

Now, I have put together an alternative using CASE, but it still doesn’t work for the edge case where Address1 is NULL (the problem is that the FullAddress will have ‘, ‘ as the first two characters)

SELECT CASE WHEN [Address1] IS NOT NULL THEN [Address1] ELSE '' END
        + CASE WHEN [Address2] IS NOT NULL THEN ', ' + [Address2] ELSE '' END
        + CASE WHEN [City] IS NOT NULL THEN ', ' + [City] ELSE '' END
        + CASE WHEN [State] IS NOT NULL THEN ', ' + [State] ELSE '' END
        + CASE WHEN [Zip] IS NOT NULL THEN ', ' + [Zip] ELSE '' END
        + CASE WHEN [Country] IS NOT NULL THEN ', ' + [Country] ELSE '' END
        AS [FullAddress]
FROM Locations

I’m a little stuck at this point. Any recommendations what to try next?

  • 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-05-28T03:01:56+00:00Added an answer on May 28, 2026 at 3:01 am

    you can use this pattern:

    SELECT
        ISNULL(Address1 + ', ', '')
        + ISNULL(Address2 + ', ', '')
        + ISNULL(City + ', ', '')
        -- ....
        AS FullAddress
    

    The result of concation NULL + ', ' is NULL => Address1 + ', ' will be NULL or valid address => ISNULL(Address1 + ', ', '') will be empty string or valid address.

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

Sidebar

Related Questions

I have already posted something similar here but I would like to ask the
I know the very similar question was posted here already ( How to change
Edit at bottom with solution I've seen a similar question to this posted before
I believe this question is slightly different than similar ones asked on here before
I noticed prior to posting this question that there have been similar questions posted
I need to convert decimal values to their fractional equivalents, similar to this previous
This question is related to this question I asked a little while back. The
I posted a similar question a while ago but haven't received any answers so
I posted a similar question earlier, but I now realize I should have been
I posted a similar question yesterday with the same code, I have rewritten and

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.