Solved

Selecting multiple varchar columns as one

Posted on 2008-10-13
2
205 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
Comment Utility
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
Comment Utility
Yep, that is the correct way.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

771 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

8 Experts available now in Live!

Get 1:1 Help Now