php-crud-api icon indicating copy to clipboard operation
php-crud-api copied to clipboard

SQL Server tables with triggers defined throw an error

Open thetechnician94 opened this issue 1 year ago • 5 comments

When inserting into a SQL Server table that has a defined trigger, the following error is produced:

{"code":9999,"message":"SQLSTATE[42000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The target table 'TableName' of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause."}

This appears to be the generated SQL server statement being generated (pulled from Wireshark, 'id' is the name of my PK):

INSERT INTO "TableName" ("Col1","Col2","Col3") OUTPUT INSERTED."id" VALUES (@P1,@P2,@P3)

This stack overflow post seems to indicate that the use of OUTPUT is unsafe, though I'm not certain of the veracity of that.

https://stackoverflow.com/questions/13198476/cannot-use-update-with-output-clause-when-a-trigger-is-on-the-table

thetechnician94 avatar Aug 14 '24 17:08 thetechnician94