SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE XXX @userId INT AS BEGIN IF @userId IS NULL RETURN 0 BEGIN TRY BEGIN TRAN --------------------------------------------- DECLARE @result INT --------------------------------------------- EXEC @result = XXX @userId IF @result <= 0 BEGIN ROLLBACK TRAN RETURN @result END --------------------------------------------- EXEC @result = XXX @userId IF @result <= 0 BEGIN ROLLBACK TRAN RETURN @result END COMMIT TRAN RETURN @userId END TRY BEGIN CATCH ROLLBACK TRAN SELECT '检测用户账户时发生异常' PRINT ERROR_MESSAGE() RETURN -209 END CATCH END