I am trying to put a try-catch statement inside a trigger using Microsoft Server 2005.
BEGIN TRANSACTION
BEGIN TRY
--Some More SQL
COMMIT TRANSACTION
Use SET XACT_ABORT OFF .When Transact-SQL statement encounter error ,it just raised the error message and the transaction continues processing. The following code is to create the trigger:
Create TRIGGER [dbo].tr_Ins_Table_Master ON [dbo].Table_Master
AFTER INSERT
AS
BEGIN
set xact_abort off
BEGIN TRY
--your SQL
INSERT INTO Table_Detail
SELECT MasterID,Name FROM INSERTED
END TRY
BEGIN CATCH
select ERROR_MESSAGE()
END CATCH
END