Dear Friends,
Please guide me to generate a auto sequential number at the time of entry.
I want to generate a product ID say P001, P002, P003....... so on. At the time of entry of Master Product details it should generate.
thanks
Hemant
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Santhosh Kumar JayaramanPosted Aug 1, 2012, 2:54 AM
Create table tbl_user(
UserId varchar(10)
)
insert into tbl_User values ('M001')
insert into tbl_User values ('M002')
insert into tbl_User values ('M043')
select * from tbl_User
Check my below stored proc
Create proc asp_GetAutoincrementedId
Begin
Declare @MaxId int
select @MaxId=MAX(SUBSTRING(Userid,2,LEN(UseriD)-1))+1 from tbl_user
Select Case when @MaxId<10 then 'M00'+ CAST(@MaxId as varchar(5))
when @MaxId<100 then 'M0'+ CAST(@MaxId as varchar(5))
when @MaxId<1000 then 'M'+ CAST(@MaxId as varchar(5)) END
END
Hemant KumarPosted Aug 1, 2012, 2:05 AM
Anyone who can help me pleaseeeeeeeeeeeeeeeeeee ?
thanks
Hemant