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

UPDATED FOR CLARIFICATION I posted a similar question a while back found here which
I know that this question is very similar to the question posted here .
This is a follow up to my question earlier here: Android: Autocomplete TextView Similar
Before I post this question, I found somehow similar question posted here . But
I've posted similar question here , but it was closed because I didn't explained
I'm trying to solve interviewstreet's median challenge. I saw a similar question posted here:
I saw a similar question being posted here, yet it did not help me
I know the very similar question was posted here already ( How to change
this question is very similar to many other questions posted on stack overflow,I have
Edit at bottom with solution I've seen a similar question to this posted before

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.