错误信息是:
当前事务无法提交,也无法支持写入日志文件的操作。回滚事务。
此处的这部分会导致错误(一旦我将 SELECT 子句注释掉,一切都会顺利进行)。
DECLARE @TSV_Target_Counter INT
DECLARE @TargetTable nvarchar(255)
DECLARE @TargetColumn nvarchar(255)
DECLARE @Value nvarchar(4000)
DECLARE @SQLSTR nvarchar(4000)
SET @TSV_Target_Counter = ( SELECT MIN(Transition_Set_Variable_ID)
FROM @TSV_WithTarget )
SET @TargetTable = ( SELECT TargetTable
FROM @TSV_WithTarget
WHERE Transition_Set_Variable_ID = @TSV_Target_Counter )
SET @TargetColumn = ( SELECT TargetColumn
FROM @TSV_WithTarget
WHERE Transition_Set_Variable_ID = @TSV_Target_Counter )
SET @Value = ( SELECT Value
FROM @TSV_WithTarget
WHERE Transition_Set_Variable_ID = @TSV_Target_Counter )
-- problem starts here
SELECT @SQLSTR = 'UPDATE Business_Partner AS BP
INNER JOIN BP_Contact AS BPC ON BP.Business_Partner_ID = BPC.Business_Partner_ID
INNER JOIN Due_Diligence AS DD ON BPC.BP_Contact_ID = DD.BP_Contact_ID
SET' + @TargetColumn + ' = ' + @Value + '
WHERE DD.Process_Instance_ID = ' + @Process_Instance_ID
-- ends here
EXEC(@SQLSTR);
难道我做错了什么?我正在尝试使用此事务测试此 SP:
BEGIN TRANSACTION T1
EXEC Process_Instance_Value_AddAlter -- the name of the SP
REVERT
ROLLBACK TRANSACTION T1