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
61 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 37

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 500 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 500 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

A quick step-by-step overview of installing and configuring Carbonite Server Backup.
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how the fundamental information of how to create a table.

766 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