日期:2014-05-18  浏览次数:20464 次

sql中insert触发器的问题
create   table   biao1
(
                Id   int   identity(1,1)   not   null,                       -- 客户编号(标识列)主键
eMail   varchar(100)   not   null,                 --电子邮箱 唯一,(客户帐户名),要验证格式(一个”@”,一个”.”)
pwd       varchar(20)   not   null,                   --密码 长度必须大于等于6位
registerTime   datetime   not   null             --注册时间,默认当前系统日期
)go

create   table   biao2
(
                customerId   int   primary   key   not   null,       --客户编号,     对应biao1   中   Id列
name   varchar(100)   not   null,                         --收货人姓名  
telephone   varchar(13)   not   null,                 --固定电话,格式为:XXXX-XXXXXXXX
mobileTelephone   char(11)   not   null,           --移动电话,必须为11位数字
address   varchar(250)   not   null               --收货地址  
)
go

create   table   biao3
(
                customerId   int   primary   key   not   null,
                eMail   varchar(100)   not   null,
                registerTime   datetime   not   null        
name   varchar(100)   not   null,                    
telephone   varchar(13)   not   null,            
mobileTelephone   char(11)   not   null,          
address   varchar(250)   not   null
)
go
如何通过插入   baio3   的同时也将   biao1   和   biao2   也插入成功     求详细解释??

------解决方案--------------------
将3条插入语句写在一个事务里,比如:
set xact_abort on
begin transaction

insert into biao1 ...

insert into biao2 ...

insert into hiao3...

commit transaction