SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to display two columns as one
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Eagle_f90
Constraint Violating Yak Guru

USA
384 Posts

Posted - 05/23/2012 :  17:39:09  Show Profile  Visit Eagle_f90's Homepage  Reply with Quote
Is it possible to create a select statement that grabs the data out of two columns and returns that data as a single column? I.E Select Column1 + Column2 AS CombindedColumn form dbo.Table?

--
If I get used to envying others...
Those things about my self I pride will slowly fade away.
-Stellvia

robvolk
Most Valuable Yak

USA
15567 Posts

Posted - 05/23/2012 :  17:43:11  Show Profile  Visit robvolk's Homepage  Reply with Quote
Yes, that's exactly how you'd do it, as long as they are both character data types, or converted to such.
Go to Top of Page

mani_12345
Starting Member

India
35 Posts

Posted - 05/24/2012 :  00:47:21  Show Profile  Reply with Quote
yes u can do it ...

select convert(varchar([size]),[col_name],1) +space(1)+ convert(varchar([size]),[col_name2],1)

try this...u vl get answer
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
48076 Posts

Posted - 05/24/2012 :  15:41:17  Show Profile  Reply with Quote
make sure you add check for NULLs and convert them to blanks or some default value if any of columns are nullable. Otherwise the concatenation causes result to be NULL if any of columns have NULL values under default conditions

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000