on 03-17-2011 6:26 AM
hi,
i am using following query for auto code generation group wise
declare @temp as char(20)
IF $[OITM.ItmsGrpCod] = 101
BEGIN
set @temp=(select isnull(max(right(ItemCode,6)),0) + 1 from OITM where (ItmsGrpCod= 101) and (len(ItemCode)=7))
set @temp='FAB'+isnull(replicate(0,6-len(@temp)),'')+@temp
select cast(@temp as char(20))
END
ELSE IF $[OITM.ItmsGrpCod] = 104
BEGIN
set @temp=(select isnull(max(right(ItemCode,6)),0) + 1 from OITM where (ItmsGrpCod= 104) and (len(ItemCode)=7))
set @temp='BRD'+isnull(replicate(0,6-len(@temp)),'')+@temp
select cast(@temp as char(20))
END
but this does not increment code automatically every time it shows me FAB000001 and BRD000001
thanks
rahul
solved
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
100 | |
11 | |
10 | |
6 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.