日期:2014-05-18 浏览次数:20481 次
CREATE PROCEDURE [dbo].[CopyNode] ( @product_id varchar(25), @product_id_new varchar(25) ) AS declare @lft int declare @rgt int if exists(select product_id from BOM where product_id = @product_id) begin SET XACT_ABORT ON BEGIN TRANSACTION select * from BOM where product_id = @product_id //如何写呢? //insert into BOM where product_id = @product_id COMMIT TRANSACTION SET XACT_ABORT OFF end
SET XACT_ABORT ON BEGIN TRANSACTION insert into BOM select @product_id_new,[product_id外的其他字段] from BOM where product_id = @product_id COMMIT TRANSACTION
------解决方案--------------------
insert into BOM select @product_id_new,其他字段 from BOM where product_id = @product_id
------解决方案--------------------
SET XACT_ABORT ON
BEGIN TRANSACTION
insert into BOM
select @product_id_new,[product_id外的其他字段]
from BOM where product_id = @product_id
COMMIT TRANSACTION