Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Numeric Column

Numeric Column

Scheduled Pinned Locked Moved Database
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    banker_kiran
    wrote on last edited by
    #1

    Hi, I have one column with numeric data type. It is auto number. i have given size numeric(9,0) now i want to pad 0. eg. if it is 1 in auto number then i want to display 000000001 if 2 then 000000002 if 10 then 000000010

    kiran banker

    K G I 3 Replies Last reply
    0
    • B banker_kiran

      Hi, I have one column with numeric data type. It is auto number. i have given size numeric(9,0) now i want to pad 0. eg. if it is 1 in auto number then i want to display 000000001 if 2 then 000000002 if 10 then 000000010

      kiran banker

      K Offline
      K Offline
      Krish KP
      wrote on last edited by
      #2

      check is this what you are looking for SELECT CASE WHEN Len('00000000' + LTrim(str(myid))) > 9 THEN SubString( '00000000' + LTrim(Str(myid)), Len('00000000' + LTrim(Str(myid))) - 9, Len('00000000' + LTrim(Str(myid))) ) END FROM tableA

      Regards KP

      1 Reply Last reply
      0
      • B banker_kiran

        Hi, I have one column with numeric data type. It is auto number. i have given size numeric(9,0) now i want to pad 0. eg. if it is 1 in auto number then i want to display 000000001 if 2 then 000000002 if 10 then 000000010

        kiran banker

        G Offline
        G Offline
        GuyThiebaut
        wrote on last edited by
        #3

        Hi Kiran, The code below will insert '15' into ten zeroes and keep it right justified. You will just need to jiggle things a bit substituting your number for '15' select stuff('0000000000',11-len('15'),len('15'),'15') Or even better select stuff(replicate('0',10),11-len(cast(15 as varchar(100))),len(cast(15 as varchar(100))),cast(15 as varchar(100))) I hope this is of help. Guy

        You always pass failure on the way to success.
        1 Reply Last reply
        0
        • B banker_kiran

          Hi, I have one column with numeric data type. It is auto number. i have given size numeric(9,0) now i want to pad 0. eg. if it is 1 in auto number then i want to display 000000001 if 2 then 000000002 if 10 then 000000010

          kiran banker

          I Offline
          I Offline
          ianhoc
          wrote on last edited by
          #4

          I think this is easier: SELECT RIGHT('00000000' + Ltrim(str(MyKey)), 8) From Table Ian

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups