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 |
|
ben_53
Yak Posting Veteran
67 Posts |
Posted - 2011-09-02 : 19:08:55
|
| Hi I want to view a column as a fixed 12 digit from my_tablecol = id (which has thousands of values)now i want to see all id with a fixed 12 digitsif originally id has a value 99, it should prefix 0000000000 before 99 to make it 12 digits if it has a value 1234 then it should put 8-0's to make it 12 digit.please help ! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-02 : 20:21:01
|
you can do likeSELECT RIGHT('000000000000' + CAST(yourfield AS varchar(12)),12) FROM Table------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-09-05 : 05:28:19
|
| orselect replace(str(col,12),' ','0') from your_tableMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|