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 |
|
wotrac
Yak Posting Veteran
98 Posts |
Posted - 2002-07-27 : 16:25:19
|
| I have 3 fields in my SQL table.Field 1 is a VARCHAR(10)Field 2 is a VARCHAR(6)Field 3 is a VARCHAR(16)I need to Concatenate fields 1 & 2 and Insert them into field 3 .But if the length of field 1 is less than 10 characters, I need to add spaces to the end of the string before adding field 2NB Field 1 can have variable field lengths from 4 to 10.If it was fixed I would be OKCan Anyone help. |
|
|
jasper_smith
SQL Server MVP & SQLTeam MVY
846 Posts |
Posted - 2002-07-27 : 16:48:16
|
Assumes no nulls and field1 has a min length of 4Gives you the idea anyway update mytableset field3 = ( LEFT( field1 + ' ', 10 ) + field2 ) HTHJasper SmithEdited by - jasper_smith on 07/27/2002 16:52:38 |
 |
|
|
ojn.
Starting Member
10 Posts |
Posted - 2002-07-29 : 17:41:13
|
| update tbset field3 = convert(char(10),field1)+field2---ojwww.rac4sql.net |
 |
|
|
|
|
|