Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

query help Expand / Collapse
Author
Message
Posted Thursday, April 4, 2013 2:37 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Thursday, April 24, 2014 8:19 PM
Points: 56, Visits: 240
Hi Please help for below requirement.

I need to combine two columns of data and insert in new column


ex: if have col1 has 1, 2, 3 and col2 has 1, 2, 3 and i need new column as col3 by combining col1 and col2 like 11, 22, 33

I have two columns liek belwo

col1 col2
1 2
1 5
6 1
2 7

I need table like below
Col1 col2 col3
1 2 12
1 5 15
6 1 62
2 7 27

Thanks
Aswin
Post #1439015
Posted Thursday, April 4, 2013 2:44 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 2:14 PM
Points: 12,952, Visits: 32,476
assuming the data types of col1 and col2 are varchars:
update SomeTable 
SET Col3 = Col1 + Col2

if they are integers, you will have to explicitly cast/convert the two columns.


Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1439018
Posted Thursday, April 4, 2013 2:59 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Thursday, April 24, 2014 8:19 PM
Points: 56, Visits: 240
Awesome..its working..
Thanks for your help
Post #1439023
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse