--try
select Title,CreateOn,DepartmentName,ParentName,CategoryName,ReportInfoId,
(select isnull(Max(Status)+1,0) FROM @PerusalDetail WHERE ReportInfoId=r.ReportInfoId AND CreateBy=r.CreateBy) as status
AS Status from @ReportInfoBase r where r.Status =@status
--不用自定义函数,查询语句直接改为:
select Title,CreateOn,DepartmentName,ParentName,CategoryName,ReportInfoId,
Status=(select isnull(max(Status)+1,0) FROM PerusalDetail WHERE ReportInfoId=@CreateBy AND CreateBy=a.ReportInfoId)
from vw_ReportInfo a where Status =@status
你如果按照你这个说的话,
你原来那个语句也是错的啊,
select Title,CreateOn,DepartmentName,ParentName,CategoryName,ReportInfoId,dbo.GetPerusalStatus(@CreateBy,dbo.vw_ReportInfo.ReportInfoId) AS Status from vw_ReportInfo where Status =@status