Hi,
I am still trying to get of triggers right, but when is working it seems the other starts (failing) again. Annoying.. but also educational :-)
When i executed the following SQL in MS SQL server is completes successfully, but when it is executed in a AFTER UPDATE trigger it fails with the error
Msg 512, Level 16, State 1, Procedure TR_PHOTO_AU, Line 37 Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
SQL;
UPDATE p2
SET p2.esb = '0'
FROM ( SELECT TOP(5) p1.esb
FROM SOA.dbo.photos_TEST p1
WHERE p1.esb = 'Q'
ORDER BY p1.arrivaldatetime ASC
) p2
Why is it not allowed to use a subquery as an expression in a trigger? And is there a workaround ?
thanks again, Peter