how to generate sequential number of certain format??
-
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
-
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
-
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....
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