/*****隱式事務*****/

/*****隱式事務*****/
/*****sql 的行為就類似一個快餐店,當你需要時,必須付款,
如果返回又想要一些額外的食物,你必須再付款。
ANSI行為就像去了飯店。你訂湯,服務員為你記賬,當你訂更多的東西時,他們負責添加到賬上
,最后你付款。
****
*/

/*****#1*****/
set  implicit_transactions  off
go
if   exists select   *   from  dbo.sysobjects  where  id = object_id ( ' nesttran ' ))
drop   table  nesttran
go
create   table  nesttran(id  int   identity ( 1 , 1 not   null ,transcount  int )
go
insert  nesttran
values ( @@trancount )
go
select   *   from  nesttran  where  id = 1
select   @@trancount   as  transcount
/*****#2*****/
begin   tran
insert  nesttran
values ( @@trancount )
commit
go
select   *   from  nesttran  where  id = 2
select   @@trancount   as  transcount
/*****#3*****/
begin   tran  
begin   tran  
insert  nesttran
values ( @@trancount )
select   @@trancount   as  transcount
commit
select   @@trancount   as  transcount
commit
go
select   *   from  nesttran  where  id = 3
select   @@trancount   as  transcount
/*****#4*****/
set   implicit_transactions  on  
go
insert   nesttran
values ( @@trancount )
commit
go
select   @@trancount   as  transcount
select   *   from  nesttran
where  id = 4
 
select   @@trancount   as  transcount
commit
select   @@trancount   as  transcount
go
/*****#5*****/
insert  nesttran
values ( @@trancount )
begin   tran
insert  nesttran
values ( @@trancount )
commit
commit
go
select   @@trancount   as  transcount
select   *   from  nesttran
where  id = 5   or  id =   6
select   @@trancount   as  transcount
commit
select   @@trancount   as  transcount
/*****#7*****/
set  implicit_transactions  off
drop   table  nesttran
go

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值