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
 How to concat more than 1 columns?

Author  Topic 

raysefo
Constraint Violating Yak Guru

260 Posts

Posted - 2006-12-08 : 08:22:10
Hi,

i want to select 2 integer and a varchar fields as one. How can i do it?
Any ideas?
thanks

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-12-08 : 08:24:10
[code]Select (Cast(IntCol1 as varchar) + ',' +
Cast(IntCol2 as varchar) + ',' +
VCharCol) as SomeCol
From Tbl[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

raysefo
Constraint Violating Yak Guru

260 Posts

Posted - 2006-12-08 : 08:51:02
SQL0402N The data type of an operand of an arithmetic function or operation "+ " is not numeric.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-12-08 : 08:51:07
Select cast(int_column as varchar(10))+','+varchar_column from table


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

raysefo
Constraint Violating Yak Guru

260 Posts

Posted - 2006-12-08 : 08:54:14
SQL0461N A value with data type "SYSIBM.INTEGER" cannot be CAST to type "SYSIBM.VARCHAR ".
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-12-08 : 09:04:13
Are you using SQL Server?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2006-12-08 : 09:05:35
This is a forum on MS SQL Server. You can try http://www.dbforums.com for questions on other RDBMS.


http://www.elsasoft.org
Go to Top of Page

raysefo
Constraint Violating Yak Guru

260 Posts

Posted - 2006-12-08 : 09:09:51
sorry for inconvenience
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-12-08 : 10:14:24
Nope, he/she is doing DB2

SELECT RTRIM(char_Col)||CHAR(int_Col)
FROM Table



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -