Solved

Selecting multiple varchar columns as one

Posted on 2008-10-13
2
238 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

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.
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
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
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.

697 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