sqlserver 算数溢出错误 求解 急!

打印出来的sql是可以正常执行的 但是执行存储会报算术溢出错误
声明的五个参数和数据库字段类型是一致的
关联表的字段E.SJEJLX (int) I.ID(decimal(9,0))
有能看出错误在哪里吗

img

CREATE PROCEDURE dbo.fun_blsj_get_xx_java
@ksrq u5_rq16='',    --发生时间区间   开始时间
@jsrq u5_rq16='',    --发生时间区间   结束时间
@sjbm u5_xh12= 0,    --事件编码
@hzlx varchar(8)='',     --患者类型
@hzxh varchar(8)=''     --患者序号

AS
declare @sql_where varchar(1000)
declare @sql varchar(1000)
SELECT @sql_where = 'where FSRQ >= ''' + @ksrq +'''  and  FSRQ <''' +@jsrq + '''  and BRJZXS = '''+@hzlx+''''
if(@sjbm <>0 and @sjbm is not null)
begin
    select @sql_where = @sql_where + ' and E.ID = '+convert(varchar(20),@sjbm)+''
end
if(@hzxh<>'' and @hzxh is not null)
begin
    select @sql_where = @sql_where + ' and PATID ='''+@hzxh+''''
end
begin
    select @sql = ' select  E.ID,PATID,SBRQ,FSRQ,SJFSKS,SJFSKSDM,I.NAME AS SJEJLXMC from AERS_EVENT E LEFT JOIN AERS_EVENTITEM I ON E.SJEJLX=CAST(I.ID AS int)  ' +@sql_where
end

BEGIN

print @sql
select  E.ID,PATID,SBRQ,FSRQ,SJFSKS,SJFSKSDM,I.NAME AS SJEJLXMC from AERS_EVENT E LEFT JOIN AERS_EVENTITEM I ON E.SJEJLX=CAST(I.ID AS int)+''+
+@sql_where
print @sql
END
GO