Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Increment Alpha Numeric

Author  Topic 

NITINMITTAL01
Starting Member

2 Posts

Posted - 2013-03-25 : 21:26:11
Hello,
Need help with in writing a Stored Procedure for Auto Alpha Numeric Generation. If I pass an Alpha numeric in the format mentioned below , I should get next number based on the following logic:

Format : It consists of 6 digit Alpha Numeric Code , where E is constant. For ex : E00001

SP should generate like this:

E00001 to E99999 when it reaches to E99999 then 9 on left will be replaced with "A"- EA0001

EA0001 - EA9999
EB0001 - EB9999
EZ0001 - EZ9999 when it reaches EZ9999 it should be incrmented to E0A001

Thanks,
Nick

UnemployedInOz
Yak Posting Veteran

54 Posts

Posted - 2013-03-26 : 00:14:41
Have you considered creating a lookup table with all the possible combinations?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-03-26 : 14:32:06
see

http://www.sqlteam.com/article/custom-auto-generated-sequences-with-sql-server

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -