我有以下代码,作为一个通用示例,我想知道如果事务以RETURN
.
BEGIN TRANSACTION
BEGIN TRY
IF NOT EXISTS(SELECT 1 FROM dbo.tblProducts WHERE intProductID = @intProductID)
BEGIN
SELECT 'Product does not exists' AS strMessage
RETURN
END
UPDATE dbo.tblProducts SET
curPrice = 10
WHERE
intProductID = @intProductID
SELECT 'Success' AS strMessage
END TRY
BEGIN CATCH
SELECT ERROR_MESSAGE() AS strMessage
IF @@TRANCOUNT > 0
ROLLBACK TRANSACTION
END CATCH
IF @@TRANCOUNT > 0
COMMIT TRANSACTION