Solved

Selecting multiple varchar columns as one

Posted on 2008-10-13
2
217 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
2 Comments
 
LVL 142

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TSQL previous 5 26
Extract string portion 2 16
SQL bit field not working as expected 3 21
TSQL - JOIN tbl columns nvarchar with int 6 0
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.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now