--试试
CREATE FUNCTION NewPickID(@type char(1))
RETURNS varchar(11) AS
BEGIN
declare @id varchar(11) , @i int/* 找出目前最大的编号*/
select @id=stuff('HS/A0000001',4,1,@type)
select top 1 @id = left(fPickId,4)+right('0000000'+convert(varchar,convert(int,right(fPickID,7))+1),7)
from PickUpWHTableIndex
where substring(fPickID,4,1)=@type
Order by fPickID descreturn @id
END
CREATE FUNCTION NewPickID(@type char(1))
RETURNS varchar(11) AS
BEGIN
declare @id varchar(11) , @i int/* 找出目前最大的编号*/
select @id=stuff('HS/A0000001',4,1,@type)
select top 1 @id = left(fPickId,4)+right('0000000'+convert(varchar,convert(int,right(fPickID,7))+1),7)
from PickUpWHTableIndex
where substring(fPickID,4,1)=@type
Order by fPickID descreturn @id
END
declare @type char(1)
select @type='A'--or 'B'
select dbo.NewPickId(@type)