declare @repeat varchar(200)
declare @todaynum varchar(200)
declare @totalnum varchar(200)
set @repeat='select Count(*) from '+@table+' where MID='+@MID+' and e1='+@e1+' and datediff(d,CDate,getdate())=0'
set @todaynum='select Count(*) from '+@table+' where MID='+@MID+' and datediff(d,CDate,getdate())=0)'
set @totalnum='select Count(*) from '+@table+' where MID='+@MID
if (exec(@repeat))>0
begin
set @Reason ='repeat'
end
else
begin
if (exec(@todaynum))>=@Usertodaynum
begin
set @Reason ='todaynum'
end
else
begin
if (exec(@totalnum))>=@Usertotalnum
begin
set @Reason ='totalnum'
end
else
begin
declare @todaynum varchar(200)
declare @totalnum varchar(200)
set @repeat='select Count(*) from '+@table+' where MID='+@MID+' and e1='+@e1+' and datediff(d,CDate,getdate())=0'
set @todaynum='select Count(*) from '+@table+' where MID='+@MID+' and datediff(d,CDate,getdate())=0)'
set @totalnum='select Count(*) from '+@table+' where MID='+@MID
if (exec(@repeat))>0
begin
set @Reason ='repeat'
end
else
begin
if (exec(@todaynum))>=@Usertodaynum
begin
set @Reason ='todaynum'
end
else
begin
if (exec(@totalnum))>=@Usertotalnum
begin
set @Reason ='totalnum'
end
else
begin
这样子应该可以:
exec(@repeat)
if(@@ROWCOUNT > 0)
begin
set @Reason ='repeat'
end
else
begin
exec(@todaynum)
if(@@ROWCOUNT >= @Usertodaynum)
begin
set @Reason ='todaynum'
end
else
begin
exec(@totalnum)
if(@@ROWCOUNT>=@Usertotalnum)
begin
set @Reason ='totalnum'
end
else 部分代码。