请教:大家帮看下这个存储过程这样写有何问题
Create Procedure Employee_Age
@Language nvarchar(5), --语言类型
@UserId int, --用户ID
@StartDate nvarchar(10), --开始时间
@EndDate nvarchar(10) --截止时间
As
Declare @strSql nvarchar(2000)
Declare @strWhere nvarchar(2000)
Declare @strTotal nvarchar(4000)
Set @strWhere=' Where e.DepartmentID=d.DepartmentID and e.CompanyID=d.CompanyID and e.DepartmentID=ud.DepartmentID and ud.UserID='+@UserId+' and (Left(IncumbencyStatus,1)<>1 and JoinDate>='''+@StartDate+''') or (Left(IncumbencyStatus,1)=1 and DimissionDate<'''+@EndDate+''') Group By d.DepartmentName Order By d.DepartmentName'
print @strWhere
肯定不对
1.ud.UserID='+@UserId+'这个地方就有问题需要用convert转换一下@UserId
2.JoinDate>='''+@StartDate+''') or (Left(IncumbencyStatus,1)=1 and 这样直接比较也不行,也需要convert一下@StartDate才能比较。