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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Formatting Numbers

Author  Topic 

rcr69er
Constraint Violating Yak Guru

327 Posts

Posted - 2008-05-20 : 04:10:51
I know this sounds like a basic question, but how do u add a leading 0 to a number, ie, 43 becomes 043

Thanks

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-05-20 : 04:30:18
SELECT '0' + CAST(Col1 AS VARCHAR(12))
FROM Table1



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

rcr69er
Constraint Violating Yak Guru

327 Posts

Posted - 2008-05-20 : 04:36:20
Can this be done in a numeric datatype?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-05-20 : 04:45:36
Try...



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

rcr69er
Constraint Violating Yak Guru

327 Posts

Posted - 2008-05-20 : 05:08:41
Hey Thanks

Is there anyway to store it in a table as numeric datatype with the leading 0?

Thanks
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-05-20 : 05:18:38
No.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-05-21 : 07:31:07
quote:
Originally posted by rcr69er

Hey Thanks

Is there anyway to store it in a table as numeric datatype with the leading 0?

Thanks


You should use varchar datatype
But consider doing the formation at the front end application

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -