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
 Combine columns

Author  Topic 

Poddy88
Starting Member

26 Posts

Posted - 2009-02-25 : 07:53:49
I need to combine 3 columns and so far can only get it working with numbers and not characters this is what iv been using for the numbers

select (server_id + router_id + switch_id)
as hardware_id
from cabinet

This works but only with numbers i need this with characters instead using

select (server_hostname + router_hostname + switch_hostname)
as Hostname
from cabinet

anybody got any ideas??

error i get from code is "invalid number"

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-02-25 : 07:57:49
[code]select convert(varchar,server_hostname) + convert(varchar,router_hostname) + convert(varchar,switch_hostname)
from cabinet[/code]
Go to Top of Page

Poddy88
Starting Member

26 Posts

Posted - 2009-02-25 : 08:05:21
Getting error "missing Expression" occuring at the first varchar, These columns im trying to conbined are already varchar2 not numbers, but when i used the previous combined method i think it tried to treat them as numbers
Go to Top of Page

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2009-02-25 : 08:06:37
varchar2 ??? are you using oracle?

Em
Go to Top of Page

Poddy88
Starting Member

26 Posts

Posted - 2009-02-25 : 08:07:26
yeh oracle
Go to Top of Page

Poddy88
Starting Member

26 Posts

Posted - 2009-02-25 : 08:07:44
sry didnt mention that
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-02-25 : 08:09:05
You might want to post this in an oracle forum then.
Go to Top of Page

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2009-02-25 : 08:25:30
in oracle you use || instead of + for concatenation.... but yes you'll get better responses in an oracle forum

Em
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-25 : 09:07:30
try www.dbforums.com
Go to Top of Page

Poddy88
Starting Member

26 Posts

Posted - 2009-02-25 : 13:03:46
Thanks guys got it sorted elancaster u were correct got that info from oracle forum, sry for the mix up guys
Go to Top of Page
   

- Advertisement -