Reputation: 1
We did an in place upgrade on one of our lower environment servers from SQL Server 2016 to SQL Server 2019. We have two databases on that server. We put both databases in compatibility level 150. We have a stored procedure that joins Table A to Table B in database A to database B.
INSERT INTO TableA (ColumnA, ColumnB, ColumnC)
SELECT A.ColumnA, A.ColumnB, B.ColumnB
FROM TableA A
INNER JOIN TableB B ON A.ColumnD = B.ColumnD
WHERE A.ColumnE = 2
When this was ran in SQL Server 2016, it inserted a unique list of data into TableA. Since upgrading to SQL Server 2019, it is duplicating some rows up to 60 times in one run. If I back the compatibility level down to 130, it goes back to being a unique list.
This only happens when the indexes are disabled. If I enable the indexes, it does not happen or if I make the SELECT
perform under MAXDOP 1.
Any ideas? Why would it work so differently? If I were to take the data that would be inserted and look at it, as shown below, it that query only returns one record.
SELECT A.ColumnA, A.ColumnB, B.ColumnB
FROM TableA A
INNER JOIN TableB B ON A.ColumnD = B.ColumnD
WHERE A.ColumnE = 2
AND A.ColumnA = 2342342
AND B.ColumnB = 9228382
Is this a bug? I've tried all the CU's to see if it's been fixed or if it was introduced by one of them. Nothing works.
Answers to a couple of the questions that I have been asked.
UPDATE:
I have a case open with Microsoft.
Upvotes: 0
Views: 452