Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Concatenate Address Columns In One Column

Posted on August 7, 2015October 17, 2021 By David Kittell

In many databases the address is properly separated into various columns but in a report you want to concatenate them.

This simple script will pull them together in one column without causing extra spaces

SELECT ltrim(isnull([address], '') + ' ' + isnull([address2], '') + ' ' + isnull([city], '') + ' ' + isnull([state], '') + ' ' + isnull([zip], '')) AS "Address"
FROM table
SELECT ltrim(CONCAT_WS('', p.firstname, ' ', p.middlename, ' ', p.lastname)) AS 'Patient Name'
FROM patient p;
Originally Posted on August 7, 2015
Last Updated on October 17, 2021
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code MSSQL SQL concatenategroup columns

Post navigation

Previous post
Next post

Related Posts

Delete Ektron User

Posted on July 29, 2013October 26, 2015

In order to force a deletion from the Ektron user list you must follow the below path. DISCLAIMER: This will remove all content that was ever created/touched by the user. –Permissions Table DELETE permissions_tbl FROM permissions_tbl INNER JOIN users ON permissions_tbl.user_id = users.user_id WHERE users.user_name = ‘dkittell’ –Group Table DELETE…

Read More

C# Application Form Closing Event Question

Posted on March 23, 2014October 26, 2015

Sometimes you have a program that you would prefer someone not close without confirming they truly meant to close it. This script will assist in providing a question before the program simply closes. private void fm1_FormClosing(object sender, FormClosingEventArgs e) { DialogResult dialogResult = MessageBox.Show("Are you sure you want to close?",…

Read More

Android Contacts – Working With Duplicates

Posted on March 26, 2014October 26, 2015

While this line is not necessary it’s a good idea to limit to this initially until you are ready to run on a larger scale. AND data1 LIKE "%<Organization Name>%" SELECT _id ,raw_contact_id ,data1 ,data4 ,data5 FROM data WHERE mimetype_id IN ( SELECT _id FROM mimetypes WHERE mimetype LIKE "%organization%"…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes