Solved

Selecting multiple varchar columns as one

Posted on 2008-10-13
2
244 Views
Last Modified: 2012-05-05
I have three varchar columns (charCol1, charCol2, charCol3).  I want to write a query that selects all three as one column with appended semicolons.  Something like

SELECT
(charCol1 + ";" + charCol2 + ";" + charCol3) as bigCharCol
FROM
 myTable

Is this possible?   What would the actual syntax be, if so?
0
Comment
Question by:HyperBPP
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 22707011
very close, actually:

SELECT
ISNULL(charCol1, '') + ';' + ISNULL(charCol2, '') + ';' + ISNULL(charCol3, '') as bigCharCol
FROM
 myTable

Open in new window

0
 
LVL 1

Expert Comment

by:crumber
ID: 22707561
Yep, that is the correct way.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to shrink a transaction log file down to a reasonable size.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question