CREATE PROCEDURE dbo.xyz @starttime datetime,@endtime datetime
 AS 
select * into #TempKQMsg from checkinout where userid=1 and left(checktime,10)>=left(@starttime,10)  and left(checktime,10)<=left(@endtime,10)
declare @temptime datetime
declare mycursor  cursor for select left(checktime,10)  from #TempKQMsg where userid=1  group by left(checktime,10)
open mycursor
fetch next from mycursor into @temptime
while @@fetch_status=0
begin
    ----------------------------------------------------- 不是节假日 -----------------------------------------------------------------------
   if((select count(*) from HolidayList where left(Datedays,10)=@temptime)=0)    
     begin
             ------------------------------------------------------------不是规定放假------------------------------------------------------------------
         if(((select datename(weekday,@temptime))<>'星期六') and ( (select datename(weekday,@temptime))<>'星期日'))
            begin
                declare @a varchar(10),@atime datetime,@b varchar(10),@btime datetime,@c1 varchar(10),@c1time datetime,@c2  varchar(10),@c2time datetime,@d varchar(10),@dtime datetime,@e varchar(10),@etime datetime
                declare @x datetime
                select @x='12:30:00.000'
                select @x=cast(@temptime+@x as datetime)
                select top 1 @a=checkinfo,@atime=checktime from #TempKQMsg where left(checktime,10)=@temptime and checkinfo='A' order by checktime asc
                select top 1 @b=checkinfo,@btime=checktime from #TempKQMsg where left(checktime,10)=@temptime and checkinfo='B' order by checktime asc
                select top 1 @c1=checkinfo,@c1time=checktime from #TempKQMsg where left(checktime,10)=@temptime and Checkinfo='C'  order by checktime asc
                select top 1 @c2=checkinfo,@c2time=checktime from #TempKQMsg where left(checktime,10)=@temptime and Checkinfo='C'  order by checktime desc
                select top 1 @d=checkinfo,@dtime=checktime from #TempKQMsg where left(checktime,10)=@temptime and Checkinfo='D'  order by checktime asc
                select top 1 @e=checkinfo,@etime=checktime from #TempKQMsg where left(checktime,10)=@temptime and Checkinfo='E'  order by checktime asc
----------------------------------------------------------判断情况------------------------
      -------------------------------------------------1---------------------
                   if(@a is not null and @b is not null and @c1 is not null and @c2 is not null  and @d is not null and @e is null)
                     begin 
                          if(@c1time<>@c2time)
                             begin
                                 if((select count(*) from  BcwKQStat where userid=1 and DateTimes=@temptime )=0)
                                   begin
                                       insert into BcwKQStat(UserId,DateTimes,AftOut) values(1,@temptime,'早退:'+cast(@dtime as varchar))
                                   end
                             end
                     end                
       ------------------------------------------------1--------------------
      ---------------------判断情况----------------------------------
            end
            -------------------------------------------------------------不是规定放假---------------------------------------------------------------------
     end
    ----------------------------------------------------- 不是节假日 -----------------------------------------------------------------------
    fetch next from mycursor into @temptime
end
close mycursor
deallocate mycursor
drop table #TempKQMsg
GO我这样写的目的是要统计考勤的信息,在写存储过程的时候,用检查语法没有错误,通过的,可是我调用的时候
exec xyz('2004-06-14','2004-06-16')
这样执行就有错误,===============================
服务器: 消息 170,级别 15,状态 1,行 1
第 1 行: '2004-06-14附近有语法错误。
===============================这是什么原因啊,请高手指教,有什么语法错误