3
我對觸發器中的事務有一些疑問,對此我還沒有找到答案。TSQL使用事務創建觸發器並嘗試捕獲塊
CREATE TRIGGER A_AI ON A
AFTER INSERT AS
BEGIN TRY --is the try block 1 transaction ? or do I have to begin the transaction?
--BEGIN TRAN: may I start the transaction like this?
-- SOME DANGEROUS OPERATIONS
COMMIT --has this sense here?
END TRY
BEGIN CATCH --silent catch no rasing errors.
ROLLBACK TRANSACTION -- does it work without BEGIN TRANSACTION? if so, is it the whole try block?
END CATCH
GO
好的,下次我會改進我的答案。謝謝,你已經解釋了我需要知道的東西! – 2010-06-28 08:46:53