• Jack Corbett - Friday, December 29, 2017 8:47 AM

    This is an even simpler option:

    WITH VTE AS
      (
       SELECT
        *
       FROM
        (
          VALUES (3),
            (25.75),
            (12),
            (125.8),
            (1000),
            (1857.5)
        ) V (I)
      )
    SELECT VTE.I, FORMAT(I*10, '0000') AS LeadingZeros FROM VTE;

    I usually avoid FORMAT due to its fame of being slow.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2