Results 1 to 2 of 2

Thread: challenge!

  1. #1
    Join Date
    Sep 2002
    Posts
    78

    challenge!

    Hi!
    Here is a challenge:
    How would I query a field in one select statement that gives me the following fixed format everytime for every row.
    for example the field value is 123 and it is an 8 character field. How can I get 00000123. All I know is the field length is always 8 but the numbers can be anywhere from 1 digit to 8 digits and I need to pad the string with leading zeroes to make sure length is always 8.

    Thanks

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    You can pad zeroes and use RIGHT function like

    select right('00000000'+ltrim(rtrim(extension)),8) from employees

Posting Permissions

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