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.
| Author |
Topic |
|
parry02
Starting Member
18 Posts |
Posted - 2006-06-20 : 08:12:58
|
| I have 2 columns 'Col1' (char) and 'Col2' (integer) I'd like to combine these 2 columns and put the result in 'Col3' (char)please help!!! |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-06-20 : 08:42:05
|
| Why would you want to do that?update tbl set col3 = col1 + convert(varchar(20),col2)==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-06-20 : 08:50:31
|
| If you use front end application, do the concatenation thereMadhivananFailing to plan is Planning to fail |
 |
|
|
parry02
Starting Member
18 Posts |
Posted - 2006-06-20 : 09:19:48
|
| thanks for that but theres a slight problem 'Col3' has leading spaces instead of zeros...Col1 has 'ABC'col2 has 1 (default value) col3 has 'ABC 1'(without the quotes! I'm after col3 to contain ABC0000001 |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-06-20 : 09:58:00
|
| update tbl set col3 = col1 + right(replicate('0',20) + convert(varchar(20),col2),20)change the last 20 (or both) to however many digits you wantare you sure col2 is an int - it should have given ABC1Maybe you need to rtrim col1update tbl set col3 = rtrim(col1) + right(replicate('0',20) + convert(varchar(20),col2),20)==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|