日期:2014-05-18 浏览次数:20494 次
if object_id('A') is not null drop table A if object_id('B') is not null drop table B create table A( aID int identity(1,1), aName varchar(10) ) go create table B( bID int identity(1,1), aID int , bAge int ) go begin tran insert into A select 'Name1'; insert into B select @@IDENTITY,20 --or insert into B select IDENT_CURRENT('A'),20 --or insert into B select SCOPE_IDENTITY(),20 commit tran select * from A select * from B
------解决方案--------------------
建议把事务写在存储过程里,而非用ADO.net的控件控制.
------解决方案--------------------
这类的工作用触发器实现最简单