--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

解决方案 »

  1.   

    这样做是不行的,这样做会提示@Status不存在的
      

  2.   


    --不用自定义函数,查询语句直接改为:
    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
      

  3.   

    你最后那个@Status本来就是传进去的嘛,
    你如果按照你这个说的话,
    你原来那个语句也是错的啊,
    select Title,CreateOn,DepartmentName,ParentName,CategoryName,ReportInfoId,dbo.GetPerusalStatus(@CreateBy,dbo.vw_ReportInfo.ReportInfoId) AS Status from vw_ReportInfo where Status =@status