How to convert number to string and append with leading 0

  • Hi,

    I try to convert a number to a n lengh string with leading 0, please help.

    25 -> '00000000025'

     

  • SELECT RIGHT(REPLICATE(`0`, 11) + CONVERT(VARCHAR(11), YourNumberColumn), 11) AS FormattedColumn FROM dbo.YourTable WHERE ...

  • SELECT REPLACE(STR(25, 11, 0), ' ', '0')

     


    N 56°04'39.16"
    E 12°55'05.25"

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply