CarCrazyBen
CarCrazyBen

Reputation: 1136

how to correct Azure SQL DB Trigger error

I wrote an AFTER INSERT Trigger in my Azure SQL DB, which works just fine from within SSMS.

However, I am working with a JavaScript developer creating an application which writes to the Parent Table. The calling application needs to capture what was actually inserted. So, the Javascript statement is: Insert Into {my Table]... OUTPUT INSERTED.* Values (..... The T-SQL OUTPUT clause description specifically states "Triggers cannot be defined on the target."

Does anyone have suggestions for another way around this limitation? Do we have write a Procedure to query the Parent and Insert Into the Child?

Upvotes: 0

Views: 121

Answers (1)

Alberto Morillo
Alberto Morillo

Reputation: 15648

DML statements cannot have any enabled triggers if the statement contains an OUTPUT clause without any INTO clause.

There's an article about this on the Microsoft SQL Programmability & API Development Team Blog.

Upvotes: 1

Related Questions