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. Web Development
  3. ASP.NET
  4. how to generate sequential number of certain format??

how to generate sequential number of certain format??

Scheduled Pinned Locked Moved ASP.NET
tutorialcsharpdatabasequestion
3 Posts 2 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
    biswa47
    wrote on last edited by
    #1

    i have a table in sqlserver2005 named emp. where the coloumns of the emp table are as follows. empid char(3), empname varchar(20), empaddrs varchar(20), empDOB dateandtime, emp_no varchar(10) i want to genertae emp_no as autogenertaed sequencitial number. where the format of the auto genertaed number for emp_no will be - "id-yyyy-nnnn" where 1st 2 places are the no of his emp_id i.e 01 or 02 like that 2nd four palces are the year of DOB i.e 2001,or 20005 like this next four places are the numbers i.e 0001 ,0002 like this(it should be sequential number). example of auto generated number are-0120010001,0219990002, 0320000003.and so on.. how will i generate this type of sequential no in asp .net (backend vb.net.) when ever i save a record for a particular employee after giving the data in the front end of their corresponding textboxes, the emp_no should be generated in the database and stored in the emp_no coloumn of emp table. (i know only how to generate auto num.by setting its identity to true.but dont know what to write in the formula filed so that i can genrate the above type of auto generated number) thanks in advance

    M 1 Reply Last reply
    0
    • B biswa47

      i have a table in sqlserver2005 named emp. where the coloumns of the emp table are as follows. empid char(3), empname varchar(20), empaddrs varchar(20), empDOB dateandtime, emp_no varchar(10) i want to genertae emp_no as autogenertaed sequencitial number. where the format of the auto genertaed number for emp_no will be - "id-yyyy-nnnn" where 1st 2 places are the no of his emp_id i.e 01 or 02 like that 2nd four palces are the year of DOB i.e 2001,or 20005 like this next four places are the numbers i.e 0001 ,0002 like this(it should be sequential number). example of auto generated number are-0120010001,0219990002, 0320000003.and so on.. how will i generate this type of sequential no in asp .net (backend vb.net.) when ever i save a record for a particular employee after giving the data in the front end of their corresponding textboxes, the emp_no should be generated in the database and stored in the emp_no coloumn of emp table. (i know only how to generate auto num.by setting its identity to true.but dont know what to write in the formula filed so that i can genrate the above type of auto generated number) thanks in advance

      M Offline
      M Offline
      mihirhp
      wrote on last edited by
      #2

      hi.... i understand your qus... but want to ask following.... 1. is emp_id is same as sequential number.... 2. u have taken emp_id char(3) then why it is 01,02,..... just clear these ..... ok....

      B 1 Reply Last reply
      0
      • M mihirhp

        hi.... i understand your qus... but want to ask following.... 1. is emp_id is same as sequential number.... 2. u have taken emp_id char(3) then why it is 01,02,..... just clear these ..... ok....

        B Offline
        B Offline
        biswa47
        wrote on last edited by
        #3

        ya i have taken emp_id as char(3) so that while i entry the value 01 in the front end it should be taken as 01 not1. if i will take emp_id as int then if i input 01 it wil take 1 only. thats why i have taken as char. No emp_id is not a sequential no..it can be any number.. sorry 4 d late response

        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