Right Justified with leading zeroes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • benchpolo
    New Member
    • Sep 2007
    • 142

    Right Justified with leading zeroes

    ColumnName: issueamount (No Decimal Places)
    Columnlength: 10
    Data: 9999

    How can I export the data of 9999 to a fixed length text (.txt) file with a leading zero infront like 0000009999?

    left(IsNull(ltr im(rtrim( issueamount)),' ')+ ' ',10)

    Thanks.
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Modify your code to:

    right(IsNull(lt rim(rtrim(cast( issueamount as varchar(5)))),' ')+ '0',10)

    -- CK

    Comment

    • deepuv04
      Recognized Expert New Member
      • Nov 2007
      • 227

      #3
      Hi,
      Try the following code

      [code =sql]
      SELECT REPLICATE('0', 10 - LEN(CAST(issuea mount AS VARCHAR(10)))) + CAST(issueamoun t AS VARCHAR(10))

      [/CODE]

      Thanks

      Comment

      Working...