我的CaseFiles
表格csfl_CaseNo
列中有数据
00001/13-14
00002/13-14
00003/13-14
00004/13-14
00005/13-14
这是我增加数字的存储过程
ALTER PROCEDURE [dbo].[HLA_CaseNo](@strFnyr as nvarchar(5),@strSuffix as nvarchar(15) OUTPUT)
AS
BEGIN
--Declarations
declare @strSuffix1 as nvarchar(15)
declare @strTmp as nvarchar(5)
declare @intNew as int
--declare @strSql as nvarchar(2000)
set @strSuffix1 = null
--Process
begin
set @strSuffix1 = (select max(csfl_caseNo) from CaseFiles where csfl_Fynyr = @strFnyr)
--set @strPrf='QUT'
end
if @strSuffix1 is null
set @intNew = 1
else
set @intNew = cast(substring(@strSuffix1,0,5) as int) + 1
print 'The value of intNew ' + cast(@intNew as nvarchar(10))
set @strTmp = cast(@intNew as nvarchar(5))
set @strTmp = (select replicate('0',5-len(@strTmp)) + @strTmp)
set @strSuffix = @strTmp + '/' + @strFnyr
结尾
我的任务是当我通过财政年度时,因为13-14
它必须将值返回为00006/13-14
,但它正在返回00002/13-14
。
为什么会这样?请帮忙