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. Generate Alpha Numeric no in sql server

Generate Alpha Numeric no in sql server

Scheduled Pinned Locked Moved Database
databasesql-serversysadminhelp
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.
  • S Offline
    S Offline
    sumit7034
    wrote on last edited by
    #1

    Hi I want to generate alpha numeric no like this: If I say length is 4 it generates like 0001 0002 0003 --- --- --- 9999 A001 A002 --- --- --- A999 B001 --- --- zzzz Please help Thanks in advance

    J W P 3 Replies Last reply
    0
    • S sumit7034

      Hi I want to generate alpha numeric no like this: If I say length is 4 it generates like 0001 0002 0003 --- --- --- 9999 A001 A002 --- --- --- A999 B001 --- --- zzzz Please help Thanks in advance

      J Offline
      J Offline
      Johan Hakkesteegt
      wrote on last edited by
      #2

      You might be able to do something like this with two columns. Put a normal running number in one column and then populate the other column based on the value in the first one: Col 1 Col 2 1 0001 ... 999 0999 ... 9999 9999 10000 A001 etc.

      My advice is free, and you may get what you paid for.

      1 Reply Last reply
      0
      • S sumit7034

        Hi I want to generate alpha numeric no like this: If I say length is 4 it generates like 0001 0002 0003 --- --- --- 9999 A001 A002 --- --- --- A999 B001 --- --- zzzz Please help Thanks in advance

        W Offline
        W Offline
        Wendelius
        wrote on last edited by
        #3

        If you want to generate the data on-the-fly, you could use table valued functions. Here's one example: Using Table-Valued Functions in SQL Server[^]

        The need to optimize rises from a bad design.My articles[^]

        1 Reply Last reply
        0
        • S sumit7034

          Hi I want to generate alpha numeric no like this: If I say length is 4 it generates like 0001 0002 0003 --- --- --- 9999 A001 A002 --- --- --- A999 B001 --- --- zzzz Please help Thanks in advance

          P Offline
          P Offline
          Prasanta_Prince
          wrote on last edited by
          #4

          SELECT CAST(RAND() * 1000 AS VARCHAR) AS [Random_Number]

          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