Database: Azure SQL
Programming language: C#.NET
System.Data.Common.DbCommand.ExecuteNonQuery() executes the merge into statement. It is not clear why the negative number is returned. Has anyone encountered a similar problem?
The program has been running for more than half a year and has not had this problem, and it has only recently appeared suddenly.
This phenomenon cannot reappear locally, and sometimes the same sql returns not a negative number, sometimes it returns a negative number, so I have not been able to find the reason.
The structure of the executed merge into statement is as follows:
MERGE
INTO TABLE_A AS A
USING (
SELECT ...
) AS B
ON (
...
) WHEN MATCHED THEN UPDATE
SET
...
WHEN NOT MATCHED THEN
INSERT (
...
)
VALUES (
...
);