Sql 触发器逻辑
A表
A列 int
B列 int
如果在插入过程中A列的值大于9,则B列自动为1.此时A列清0;
雁
SQL code:
create trigger tri_insert_tb
on tb
instead of insert
as
if exists(select 1 from inserted where a>9)
begin
insert tb(a,b)
select 0,1
from inserted
where a>9
end
树兄的有点问题
看来基本看错了,除非a is null
for触发器写法(假设id是主键)
SQL code:
create trigger tri_insert_tb
on tb
for insert
as
update tb set
a=0,b=1
from tb,inserted i
where i.id=tb.id and i.a>9
go
相关问答:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
我一个项目,有个插入操作,具体是这样的:
我有进货信息表。在出货时选择相应的进货信息,输入数量,选择部门后,点保存按钮,由于网络延时,点一下没有反映,于是用户就又点一下,导致一次插入了两条记录:
例:
......
场景如下:
客户把备份好的数据库,发给我,我在本机还原后,运行写好的存储过程,比较快,并且在实施那边运行同样比较快。但是当实施在客户那边运行的时候速度就非常的慢,时间超出了程序的时间限制。远程在客户那 ......
现在有两张表:文章主表A(articleId,articleTitle),文章评论表B(commentId,articleId,commentTitle)
现在我想实现这样的功能:列出文章列表,其中每篇文章标题下面列出此文章的前2个文章评论,请问sql语句怎么写啊 ......
sqlserver2005 建立的数据库,与手持pda传输数据,最近突然出现无法传递数据的问题,pda端提示的错误时outofmemoryexception,但是pda上面的容量没有问题,
sqlserver的日子上的错误如下:
日期 2010-1-25 14:45: ......