我有以下T-SQL:
USE [MYDB]
GO
SET XACT_ABORT, NOCOUNT ON
GO
BEGIN TRANSACTION;
BEGIN TRY
ALTER TABLE [dbo].[ContactRole]
DROP CONSTRAINT [FK_8bff7074914bc29885004c0a323]
GO
END TRY
BEGIN CATCH
SELECT
ERROR_NUMBER() AS ErrorNumber ,ERROR_SEVERITY() AS ErrorSeverity
,ERROR_STATE() AS ErrorState ,ERROR_PROCEDURE() AS ErrorProcedure
,ERROR_LINE() AS ErrorLine ,ERROR_MESSAGE() AS ErrorMessage;
IF @@TRANCOUNT > 0
ROLLBACK TRANSACTION;
END CATCH
IF @@TRANCOUNT > 0
COMMIT TRANSACTION;
如果说:
Msg 102, Level 15, State 1, Line 9
Incorrect syntax near FK_8bff7074914bc29885004c0a323 .
单凭交易,或者在交易中,不存在差错。