Go Premium for a chance to win a PS4. Enter to Win

x
?
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
Medium Priority
?
200 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 38

Expert Comment

by:Geert Gruwez
ID: 41771525
too much comments
remove the comment clutter

it's useless
0
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 2000 total points (awarded by participants)
ID: 41771526
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
ID: 41771610
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 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points (awarded by participants)
ID: 41773219
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

927 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