Is it possible to apply a condition on an output.inserted statement?
DECLARE @tblA TABLE (foo INT)
DECLARE @tblOut TABLE (bar INT)
INSERT INTO @tblA
OUTPUT inserted.foo INTO @tblOut(bar) --WHERE foo = 1
VALUES (1),(2),(3)
sql serversql-server-2016
Is it possible to apply a condition on an output.inserted statement?
DECLARE @tblA TABLE (foo INT)
DECLARE @tblOut TABLE (bar INT)
INSERT INTO @tblA
OUTPUT inserted.foo INTO @tblOut(bar) --WHERE foo = 1
VALUES (1),(2),(3)
Best Answer
As far as I know, it is not possible to apply condition on
OUTPUT
directly, but you can achieve what you need using output of theMERGE
: