SQL触发器写法
我想写一个触发器,当table表中的a,b,c字段为True时,使得d字段更新为true,在线等...
我想写一个触发器,当table表中的a,b,c字段为True时,使得d字段更新为true,在线等
展开
展开全部
create trigger dbo.SetTrue
on YourTable for update
as
if exists (select 'True'
from inserted as i
where i.a = true and i.b = true and i.c = true )
update YourTable
set YourTable.d = true
where YourTable.a = true and YourTable.b = true and YourTable.c = true
on YourTable for update
as
if exists (select 'True'
from inserted as i
where i.a = true and i.b = true and i.c = true )
update YourTable
set YourTable.d = true
where YourTable.a = true and YourTable.b = true and YourTable.c = true
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
ALTER trigger [dbo].[trg_allwage]
on [dbo].[Factory]
after insert
as
begin
declare @allwages float
select @allwages=sum(wages) from dbo.employee
update dbo.Factory set allwages=@allwages where factory='A1001'
end
这样改试一下。
on [dbo].[Factory]
after insert
as
begin
declare @allwages float
select @allwages=sum(wages) from dbo.employee
update dbo.Factory set allwages=@allwages where factory='A1001'
end
这样改试一下。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
declare @wages float,@allwages float
select @wages=sum(wages) from dbo.employee
print @allwages
update dbo.Factory set allwages=@wages where factory='A1001'
select @wages=sum(wages) from dbo.employee
print @allwages
update dbo.Factory set allwages=@wages where factory='A1001'
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
create trigger t_update on [table]
for update
as
update [table] set d=1 where a=1 and b=1 and c=1
for update
as
update [table] set d=1 where a=1 and b=1 and c=1
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询