------解决方案-------------------- 删除的SQL就这么写好了
--检索
--select * from A where ID in (select AID from B)
--删除
--delete from A where ID in (select AID from B) ------解决方案--------------------
什么叫获取相应的值?相应是什么意思? ------解决方案--------------------
这位仁兄说的好,这种一增一删的用事务处理,代码如下
Select * from dbo.A where ID=2
Begin TransAction
declare @ID int
declare @error int
set @ID=1 --A表ID
set @error=0
Insert into dbo.B(AID,Name,Age,Address) select * from dbo.A where ID=@ID
set @error=@error+@@error
Delete from dbo.A where ID=@ID
set @error=@error+@@error
if(@error>0)
begin
print('Failed')
rollback TransAction
end
else
Begin
print('Succeed')
Commit TransAction
End