有一些修改表字段的语句,想实现在任一条修改出错时回滚的效果--1、增加问题表dbo.ISS_question字段qNumsOfRow:纵向0 横向>0
alter table dbo.ISS_question add qNumsOfRow int null
--初始化该字段
update dbo.ISS_question set qNumsOfRow = 0 where qNumsOfRow is null--2、增加问题表dbo.ISS_question分页描述字段nextpageinfo
alter table dbo.ISS_question add nextpageinfo varchar(200) null--3、增加问卷表dbo.ISS_app是否针对被评对象字段isLimitObj:0否1是
alter table dbo.ISS_app add isLimitObj smallint null
--初始化该字段
update dbo.ISS_app set isLimitObj = 0 where isLimitObj is null请高手们写出具体代码哦~~~
alter table dbo.ISS_question add qNumsOfRow int null
--初始化该字段
update dbo.ISS_question set qNumsOfRow = 0 where qNumsOfRow is null--2、增加问题表dbo.ISS_question分页描述字段nextpageinfo
alter table dbo.ISS_question add nextpageinfo varchar(200) null--3、增加问卷表dbo.ISS_app是否针对被评对象字段isLimitObj:0否1是
alter table dbo.ISS_app add isLimitObj smallint null
--初始化该字段
update dbo.ISS_app set isLimitObj = 0 where isLimitObj is null请高手们写出具体代码哦~~~
解决方案 »
- SQL数据库:存储过程查询超时,超过30秒
- 大家帮帮忙啊。。。。。。。。明早结贴.................
- 存储过程问题 ,在线等待
- 如何删除2005 SQL Server服务 - SQL Server已从添加删除程序中删除了
- 急!!!!请高手赐教:Analysis Services中建立多维数据集的问题
- 有没工具直接把简体中文转为繁体中文的
- 如何清除SQL Server 缓存
- 级联引用完整性约束的性能问题
- asp 为什么调用存储过程总是失败阿???
- 如何查询包含某几个字的所有记录(数据库SQL Server)
- replace不能用于变量吗?
- 奇怪,郁闷,行转列为什么结果不对?大家帮帮我
begin tran mytran
alter table dbo.ISS_question add qNumsOfRow int null
alter table dbo.ISS_question add nextpageinfo varchar(200) null
alter table dbo.ISS_app add isLimitObj smallint null
go
if @@error<>0 begin
rollback tran mytran
end
else begin
commit tran mytran
end没效果啊
指定当 Transact-SQL 语句产生运行时错误时,Microsoft® SQL Server™ 是否自动回滚当前事务。语法
SET XACT_ABORT { ON | OFF }注释
当 SET XACT_ABORT 为 ON 时,如果 Transact-SQL 语句产生运行时错误,整个事务将终止并回滚。为 OFF 时,只回滚产生错误的 Transact-SQL 语句,而事务将继续进行处理。编译错误(如语法错误)不受 SET XACT_ABORT 的影响。对于大多数 OLE DB 提供程序(包括 SQL Server),隐性或显式事务中的数据修改语句必须将 XACT_ABORT 设置为 ON。唯一不需要该选项的情况是提供程序支持嵌套事务时。有关更多信息,请参见分布式查询和分布式事务。 SET XACT_ABORT 的设置是在执行或运行时设置,而不是在分析时设置。
不能回滚.