if object_id('P_EMRealMonitor_test')is not null
drop proc P_EMRealMonitor_test
go
create procedure [P_EMRealMonitor_test] as
SET NOCOUNT On
begin
declare @ChildID int while @@ROWCOUNT > 0--这里第一次执行时,没有返回受上一语句影响的行数,所以下面语句也不能执行,不知道大家有什么好方法吗? begin
select top 1 @ChildID=b.ChildiD from EMRealMonitor b where IsCheck=0 order by b.yymmdd desc ,b.cardtime desc
update EMRealMonitor set IsCheck=1 where ChildiD=@ChildID
if exists (
select top 1 a.yymmdd,a.cardTime,a.mid,a.empid from EMRealMonitor a ,
(select b.yymmdd,b.cardTime,b.mid,b.empid from EMRealMonitor b where b.ChildiD=@ChildID)c,
(select mid1,mid2,intervaltiem from EMRealMonitor_test) d
where a.empid=c.empid and c.mid=d.mid2
and
DATEDIFF(ss,case when a.yymmdd<c.yymmdd then dateadd(hh,-24,a.cardTime) else a.cardtime end,c.cardTime)>0--d.intervaltiem*60--考虑隔天打卡时
order by a.cardtime desc
)
begin
update EMRealMonitor set IsExcept=1 where ChildID=@ChildID
end
end
end
drop proc P_EMRealMonitor_test
go
create procedure [P_EMRealMonitor_test] as
SET NOCOUNT On
begin
declare @ChildID int while @@ROWCOUNT > 0--这里第一次执行时,没有返回受上一语句影响的行数,所以下面语句也不能执行,不知道大家有什么好方法吗? begin
select top 1 @ChildID=b.ChildiD from EMRealMonitor b where IsCheck=0 order by b.yymmdd desc ,b.cardtime desc
update EMRealMonitor set IsCheck=1 where ChildiD=@ChildID
if exists (
select top 1 a.yymmdd,a.cardTime,a.mid,a.empid from EMRealMonitor a ,
(select b.yymmdd,b.cardTime,b.mid,b.empid from EMRealMonitor b where b.ChildiD=@ChildID)c,
(select mid1,mid2,intervaltiem from EMRealMonitor_test) d
where a.empid=c.empid and c.mid=d.mid2
and
DATEDIFF(ss,case when a.yymmdd<c.yymmdd then dateadd(hh,-24,a.cardTime) else a.cardtime end,c.cardTime)>0--d.intervaltiem*60--考虑隔天打卡时
order by a.cardtime desc
)
begin
update EMRealMonitor set IsExcept=1 where ChildID=@ChildID
end
end
end
解决方案 »
- 问个简单的
- 数据库复制怎么搞?
- SQL Server创建返回值是表变量的函数
- 今天安装测试工具QC,安装的时候连接数据库时候老是连接不上,我的数据库是SQL server 2005的,同学们都连接起了他们是SQL server 2000
- 开心网的好友动态怎么设计数据库结构
- sql更新update多条select信息时如何不脏读排他
- 有关Red Gate的SQL Compare数据库对比工具的问题
- SQL SERVER在asp.net中可利用字符串生成连接但是不能手动添加数据源 没有服务器名选项 打开配置管理器 显示无法连接到报表服务器WMI提供程序
- 关于sql server7.0数据库中image类型字段问题!
- 看看,怎回事?
- 求这个简单的触发器
- win7 安装 sql2008 ,2337 错误,高手来
如果有多表,表之间如何关联?
发帖注意事项
http://topic.csdn.net/u/20091130/21/fb718680-98ff-4afb-98d8-cff2f8293ed5.html?24281