There is no way to auto generate alphanumric identity, you have to do it manually.
First you must fix length of alpha chars and length of numeric chars.
eg.
student table
STUDCODE STUDNAME
STD00001 Ramesh Mehta
STD00002 Samir Patel
Here alpha length is 3 and number length is 5
Declare @newnumber INTEGER
DECLARE @newstdcode varchar(8)
--find max number
SELECT @newnumber=ISNULL(MAX(substring(STUDCODE,4,8)),0)+ 1 FROM STUDENT
--prepare your code by padding 0's
@newstdcode ='STD'+replicate('0',5-len(str(@newnumber,5,0)))
INSERT INTO STUDENT (STUDCODE,STUDNAME) VALUES (@newstdcode,'New Student name')
urt
|