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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Append 2 colums in Sql Server

Author  Topic 

palaparu
Starting Member

20 Posts

Posted - 2011-01-25 : 09:40:38
Hi Friends can any one tell me the syntax for appending the columns

I Have 2 columns named Col1 and Col2

Col1 col2 Col3 (Col1 + Col2)
123 456 123456 (not the addition of 123+456 = 579)

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-01-25 : 10:42:35
convert(varchar(3),col1)+convert(varchar(3),col2)

or maybe col1*1000+col2
or
right(' '+convert(varchar(3),col1),3)+right(' ' + convert(varchar(3),col2),3)

depends what you want to cater for the numbers being less than 3 digits and what datatype you want the result to be.


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

palaparu
Starting Member

20 Posts

Posted - 2011-01-25 : 11:32:14
thank you so much dude
Go to Top of Page
   

- Advertisement -