22,300
社区成员




--触发器
create trigger tr_shuaxin
on tb_shuaxin for insert,update
as
begin
if exists(select 1 from inserted where intime<=getdate())
begin
update tb_House set uptime=intime from inserted where houseid=id
update tb_shuaxin set upok=1 from inserted a where a.houseid=tb_shuaxin.houseid
end
end
--过程
create proc tr_shuaxin
as
begin
if exists(select 1 from tb_shuaxin where intime<=getdate())
begin
update tb_House set uptime=intime from tb_shuaxin where houseid=id and intime<=getdate()
update tb_shuaxin set upok=1 where intime<=getdate()
end
end
CREATE PROCEDURE P_test
AS
BEGIN
SET NOCOUNT ON;
if exists(select 1 from tb_shuaxin where upok=0 and intime<=GETDATE())
begin
update tb_House set uptime=tb_shuaxin.intime
from tb_shuaxin
where tb_House.id = tb_shuaxin.houseid and upok=0 and intime<=GETDATE()
update tb_shuaxin set upok=1
where upok=0 and intime<=GETDATE()
end
END
GO