Generate Sequence number with Prefix

Posted by Krishnasamy2008 under ASP.NET on 5/17/2012 | Points: 10 | Views : 2692 | Status : [Member] | Replies : 2
Hi

I want to generate an unique 15 digit sequence number with prefix.

eg: TR0000000000001 , TR0000000000002 , TR0000000000003..............TR0000000000015,................TR0000000000250

I will start from 1 and then append the required prefix at the First 2 characters(TR). I want to append Zeros to make a 15 digit number.

I will store the last increment number in table and then add 1 and store it again during next generation.
My table will contains these are fields SequenceID,SequenceType,NextNumber and Prefix.Can you all suggests the best way to achieve this.

Thanks

Krishna




Responses

Posted by: rajarsn-7627 on: 5/17/2012 [Member] Starter | Points: 25

Up
0
Down
You can do it in either on frontend or backend.

If you are doing in ASP.net, you can declare an Int32 variable, set the prefix, set the length excluding the id and update to the db.

If you are using db, you can create a procedure for the string manipulation for creating the ID , while inserting data. So call first the IDCreation procedure and then call your custom procedure for updating data.

Let me know if it works for you.

Krishnasamy2008, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Krishnasamy2008 on: 5/17/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Friends,

Thanks for your valuable response.I have followed second approach.

Thanks,
Krishna.K

Krishnasamy2008, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response