Solved

Msg 3609, Level 16, State 1, Line 1 The transaction ended in the trigger. The batch has been aborted.

Posted on 2016-08-26
6
34 Views
Last Modified: 2016-10-14
this is my trigger
SET IMPLICIT_TRANSACTIONS OFF 
GO 
ALTER TRIGGER [dbo].[myInsertTrigger]
ON [migratedData].[dbo].[t1] 
FOR INSERT
AS 

		--DECLARE @F1 VARCHAR(50)
		--DECLARE @F2 VARCHAR(50)
		--SELECT @F1 = (SELECT [f1] FROM Inserted)
		--SELECT @F2 = (SELECT [f2] FROM Inserted)
		--PRINT @F1
		--PRINT @F2

SET XACT_ABORT ON 
 COMMIT
	BEGIN  TRY
			INSERT INTO OPENQUERY (MYSQL, 'SELECT * FROM t2')
			--VALUES(@F1,@F2)
			VALUES('DDDDDD','DDD@F2')
	
	END TRY
	BEGIN CATCH
		PRINT 'FFLF'
	END CATCH
	
	

Open in new window


what is my error


please help me

Thanks
0
Comment
Question by:yoosuf pp
  • 2
6 Comments
 
LVL 36

Expert Comment

by:Geert Gruwez
Comment Utility
too much comments
remove the comment clutter

it's useless
0
 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 500 total points (awarded by participants)
Comment Utility
the error is the COMMIT (in the trigger). remove that one, and it's ok
see more on this support note:
https://technet.microsoft.com/en-us/library/ms187844(v=sql.105).aspx
using @@trancount etc ...
0
 

Author Comment

by:yoosuf pp
Comment Utility
sir
without commit

i get this error

OLE DB provider "MSDASQL" for linked server "MYSQL" returned message "[MySQL][ODBC 5.1 Driver]Optional feature not supported".

(0 row(s) affected)
Msg 3616, Level 16, State 1, Line 1
An error was raised during trigger execution. The batch has been aborted and the user transaction, if any, has been rolled back.
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points (awarded by participants)
Comment Utility
I had seen that also on my side, and there is no direct solution within a trigger.
You will need an async solution
Trigger inserts into a local table, and a job to do the insert into the mysql table from there.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Learn about cloud computing and its benefits for small business owners.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now