Suggest removing the ';' from line 835 and adding to line 837. i.e.
IF @delete_if_not_matched=1
BEGIN
SET @output += @b + 'WHEN NOT MATCHED BY SOURCE THEN '
SET @output += @b + ' DELETE'
END
IF @include_rowsaffected = 1
BEGIN
SET @output += @b + 'OUTPUT $action INTO @mergeOutput'
END
SET @output += @b + ';'
When calling the sproc using
@include_rowsaffected = 0
results in an error:For example:
Suggest removing the ';' from line 835 and adding to line 837. i.e.