suppose think like you primary key column values like
RA00006701 -- --
RA00006702 -- --
RA00006703 -- --
RA00006704 -- --
In order to get the max(id) as RA00006705 do the following
Declare @maxid nvarchar(15)
select @maxid=substring(max(id),1,2)+RIGHT('00000000'+convert(nvarchar,ISNULL((MAX(Convert(int,substring(id,3,8)))),0)+ 1),8) from tbl_yourtable;
select @maxid
Tag: Incrementing the primary key string value in sql server
No comments:
Post a Comment