set @edate = inowork from inwork where id = @id
if @edate is null
update inwork set inwork = getdate() where id = @id
else
update inwork set outwork = getdate() where id = @id
if @edate is null
update inwork set inwork = getdate() where id = @id
else
update inwork set outwork = getdate() where id = @id
INSERT INTO inwork (ID, inwork) VALUES (@ID, getdate())
create proc kq_taday_insert
@id nvarchar (10),
@a datetime
as
select @a=inwork from inwork where (id=@id) and (inwork=getdate())
if @a is null--签到
insert into inwork (id,inwork) values(@id,getdate())
else --签退
update inwork set outwork=getdate() where id=@id
对吗?
可以根据你的表设计做适当的修改
@id nvarchar (10),
@a datetime
as
select @a=inwork from inwork where (id=@id) and convert(char(10),inwork,111)=convert(char(10),getdate(),111)
if @a is null--签到
insert into inwork (id,inwork) values(@id,getdate())
else --签退
update inwork set outwork=getdate() where id=@id