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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:14:56+00:00 2026-05-18T00:14:56+00:00

Have a 5 columns of address data. I need to concatenate these fields into

  • 0

Have a 5 columns of address data. I need to concatenate these fields into a single address with spaces in between the values if they exist. If the column has a null value I should skip it and not enter any space.

select 
        case 
            when street_number != '' THEN (cast(street_number as int)) 
        end as street_number,
        case
            when street_ext != '' then
                    case
                        when street_ext = 50 then '1/2'
                    end
        end as street_ext,
        case
            when street_direct ! = '' then street_direct
        end as street_direct,
        case
            when site_street ! = '' then site_street
        end as site_street,
        case
            when site_address ! = '' then site_address
        end as site_address
    from parcel 

what I’d like to do is have a variable and assign it to the value of the first column street_number, then when I move on to the next column, street_ext, if it isn’t null I’d like to check to see if the variable is null and if not, append a space and the value…and so on down the road.

I’m rusty as hell and could use a push in the right direction.

Thanks everyone.

  • 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-18T00:14:56+00:00Added an answer on May 18, 2026 at 12:14 am

    Use the “+” to concatenate strings in TSQL:

    SELECT CASE 
             WHEN LEN(p.street_number) > 0 THEN p.street_number + ' ' 
             ELSE '' 
           END +
           CASE 
             WHEN p.street_ext = 50 THEN '1/2'
             WHEN LEN(p.street_ext) > 0 THEN ''
             ELSE p.street_ext
           END + ' ' +
           CASE 
             WHEN LEN(p.street_direct) > 0 THEN p.street_direct + ' '
             ELSE ''
           END + 
           CASE 
             WHEN LEN(p.site_street) > 0 THEN p.site_street + ' '
             ELSE ''
           END  + 
           CASE 
             WHEN LEN(p.site_address) > 0 THEN p.site_address + ' '
             ELSE ''
           END AS full_address
    FROM PARCEL p
    

    The LEN function returns zero if the string value is NULL, or a zero length string.

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

Sidebar

Related Questions

MYSQL Database: I have a table of data that I need to put into
Currently have a table .. and need to start adding new data columns to
I have two columns say Main and Sub . (they can be of same
I have two columns. Column E extends up to 99504 (values) and column I
I have two fields, email and addlEmail . I need a select that only
I have a text file containing data/fields which are separated by exact column no.
If I have a data table like this id, Name, Address, Status How would
I have two table and I need to copy the data across from SRCServiceUsers
I need a single mysql table to contain both static and dynamic data so
How to add multiple column's data into a single column in SQL Server? I

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.