Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 concatenating two columns in select statement

Author  Topic 

crugerenator
Posting Yak Master

126 Posts

Posted - 2008-12-17 : 17:14:44
So I was wondering how I could go about concatenating two columns in order to return their values as one value. For example:

SELECT hello,
(color+" "+animal) as name
FROM table1



sample data:

hello color animal
hi red dog
hey blue bug
yo gold fish


What should be returned:

hello name
hi red dog
hey blue bug
yo gold fish


Thanks, have had trouble finding out how to do this.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-12-17 : 17:19:27
SELECT hello, color + ' ' + animal AS [name]
FROM table1

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

crugerenator
Posting Yak Master

126 Posts

Posted - 2008-12-17 : 17:22:08
damn, that's easy. Thanks
Go to Top of Page
   

- Advertisement -