Hello, SQL2008R2
Question one if you execute a TRUNCATE TABLE can this be rolled back?
In a Try/Catch if I include Raiseerror then do a Rollback with the error still work?
Notice that the raiserror code is directly from BOL.
Thanks
djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!
Question one if you execute a TRUNCATE TABLE can this be rolled back?
In a Try/Catch if I include Raiseerror then do a Rollback with the error still work?
Code:
TRY CATCH
BEGIN TRANSACTION My1;
TRUNCATE TABLE MyTable;
.
. My code here
.
COMMIT TRANSACTION My1;
END TRY
BEGIN CATCH
DECLARE @ErrorMessage NVARCHAR(4000);
DECLARE @ErrorSeverity INT;
DECLARE @ErrorState INT;
SELECT
@ErrorMessage = ERROR_MESSAGE(),
@ErrorSeverity = ERROR_SEVERITY(),
@ErrorState = ERROR_STATE();
RAISERROR (@ErrorMessage, -- Message text.
@ErrorSeverity, -- Severity.
@ErrorState -- State.
);
ROLLBACK TRANSACTION My1;
END CATCH
Thanks
djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!