CREATE TABLE TB(A INT,B INT ,C AS A+B)程序里面直接检查TEXTBOXA 的值,TEXTBOXB的值,转成INT加好后直接赋值给C
能把这个检查TEXTBOXA过程 也些出来吗
那就用触发器吧。 --> 测试数据: tb if object_id('tb') is not null drop table tb create table tb (a varchar(5),b varchar(5),c int) go--创建触发器 create trigger tri_tb on tb for insert,update as update tb set c=cast(right(b.a,1) as int)+cast(right(b.b,1) as int) from tb,inserted b where tb.a=b.a and tb.b=b.b go --测试: insert into tb(a,b) select '1001','1003' insert into tb(a,b) select '1003','1002' insert into tb(a,b) select '1004','1001' goselect * from tb
能把这个检查TEXTBOXA过程 也些出来吗
那就用触发器吧。
--> 测试数据: tb
if object_id('tb') is not null drop table tb
create table tb (a varchar(5),b varchar(5),c int)
go--创建触发器
create trigger tri_tb on tb for insert,update
as
update tb set c=cast(right(b.a,1) as int)+cast(right(b.b,1) as int) from tb,inserted b
where tb.a=b.a and tb.b=b.b
go
--测试:
insert into tb(a,b) select '1001','1003'
insert into tb(a,b) select '1003','1002'
insert into tb(a,b) select '1004','1001'
goselect * from tb