Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2003
    Location
    Cleveland USA
    Posts
    184

    Unanswered: How do I insert leading zeros?

    I have a text field that contains a number. The number can have up to seven digits, no negatives and no decimal points. The tricky part is that I will be exporting the data to a mainframe system that needs seven digits, so I have to fill in any leading zeros. For example, '23' has to be exported as '0000023'. I want to fill in the zeros when I export because it'll slow down the data entry clerks too much to have to count the zeros and type them in themselves.

    So, how can I format the leading zeros? I want to either format the field or have a way to add them in as I output to the text file.

  2. #2
    Join Date
    Jul 2004
    Location
    Blackburn, UK
    Posts
    169
    If i was going to insert them into a table to export then i would do this...

    Code:
    SELECT Format([Field],"0000000") AS FieldTest INTO testtbl
    This should put the required number of zero's in front of it?

  3. #3
    Join Date
    Aug 2003
    Location
    Cleveland USA
    Posts
    184

    Talking

    Duh, thanks. That's pretty easy.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •