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 |
|
KabirPatel
Yak Posting Veteran
54 Posts |
Posted - 2006-12-05 : 09:25:52
|
| Hi all,I have data in a SQL Server table of type varchar(6). Each record in the column is a number of 2, 3 or 4 digits.e.g. 22, 130, 1000, 60 etc...I want to update all the values in the column so that they are always 4 characters long and have leading zeros.e.g. 0022, 0130, 1000, 0060 etc...How could I go about doing this?ThanksKabir |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-12-05 : 09:27:58
|
| update yourtablenamehereset yourcolumnnamehere = right(replicate('0', 4) + yourcolumnnamehere, 4)Peter LarssonHelsingborg, Sweden |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-12-05 : 09:48:35
|
| FYI, Formatting is front end issue. If you use front end application like VB6, you can useFormat(data,"0000")MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|