过程1:CREATE procedure test
@t int
as
set nocount on
begin
update testtable set id=1 where id=2
end
GO
================
过程2:CREATE procedure test
@t int
as
set nocount on
begin
begin tran
update testtable set id=1 where id=2
commit tran
end
GO过程2比过程1多了begin tran和commit tran。过程2是不是多余的写法?过程1会自动提交事务吗?谢谢!
@t int
as
set nocount on
begin
update testtable set id=1 where id=2
end
GO
================
过程2:CREATE procedure test
@t int
as
set nocount on
begin
begin tran
update testtable set id=1 where id=2
commit tran
end
GO过程2比过程1多了begin tran和commit tran。过程2是不是多余的写法?过程1会自动提交事务吗?谢谢!
解决方案 »
- 数据不能重复可以设主键两个字段且还一个外键该怎么设呢?
- [问小F]
- 用openrowset这句话导出到ACCESS可以,但去到其他机子上就不行
- 如何查看SQL2000后台操作记录
- 在连接到 SQL Server 2005 时,在默认的设置下SQL Server不允许进行远程连接可能会导致此失败。error:26
- 怎么样才能从数据库中查询20到30中的记录?
- 一个系统,如何给它制定数据库标准?
- 如果簡歷轉化繁體。存入到SQL中啊!!!!!!!!!!1
- sqlserver 中能否时间触发.
- mysql year字段对应java java.sql.Date问题
- 回杭州老家找份软件开发工作
- 请教各位高手,写一个.bat之类的脚本,如何将远端SQL数据库里面的数据批量导出到本地,很急很急,谢谢
单条更新语句具有隐形事务。
see:if object_id('tb') is not null drop table tb
if object_id('ta') is not null drop table ta
go
create table tb(id int, x varchar(10))
create table ta(id int, x varchar(9))
go
insert tb select 1,10
union all select 2,'0123456789'
go
update tb set x=x+'1'
go新开窗口执行
select * from tb
/*
10
0123456789
*/
insert ta select id,x from tb新开窗口执行
select * from ta
/*
无记录
*/
过程2中是显式事务
2中的begin tran 和commit tran可以不要