Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help Formatting Number

Status
Not open for further replies.

RichardParry

IS-IT--Management
Aug 28, 2002
91
GB
Hi All,

I wonder if you guys can help - I have a standard integer field returning numbers ranging 1 to 10, however I need to format single integers 01, 02, 03, 04, 05, 06, 07, 08, 09, 10 etc. I tried this using the Decimal function within T-SQL, but pretty sure the reason this isn't working is because of no decimal in the integer :)

I could do this in VB with FormatNumber easy, but unfortunately this is purely a T-SQL exercise (View).


Thanx!!! Richard
 
Numbers cannot have a leading 0. It can't be done.

However, if you convert the number to a varchar, you can accomplish your goal.

Code:
Select Right('0' + Convert(VarChar(2), ColumnName), 2)
From   TableName

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
If stars were pennies, George....

< M!ke >
[small]I can say nothing, which is cowardly, I can lie, which is immoral, or I can tell the truth, which will upset people. - Tiki Barber[/small]
 
>> If stars were pennies, George....

...would be very poor. Now if stars were hundred dollar bills then George would be my bestest friend. [bigcheeks]

Well Done is better than well said
- Ben Franklin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top