?
Solved

Selecting multiple varchar columns as one

Posted on 2008-10-13
2
Medium Priority
?
251 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 2000 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

770 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