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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-12-22 : 07:49:32
|
| balaji writes "i have a column called fileno consists of values with leading zeros like '022545','0003235','004566'.....how to remove those leading zeros from the columnkindly revert me with the answer" |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-12-22 : 07:54:48
|
| select fileno, cast(fileno as bigint), cast(fileno as int)from <YourTableNameHere>Peter LarssonHelsingborg, Sweden |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-12-22 : 08:36:46
|
| 1 If those strings are only numbers, above suggestion will work2 If you have data like '0000123HL98', that wont workMadhivananFailing to plan is Planning to fail |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2006-12-22 : 09:39:04
|
As long as you don't have any embedded (non-leading/non-trailing) spaces, this will work too:SELECT Replace(Ltrim(Replace(fileno, '0', ' ')), ' ', '0') FROM myTable |
 |
|
|
|
|
|