I want to update records on a view and get back the updated records to process them in my application, the code is working fine for almost cases, but for a specific senario when I have more than 22000 records on the view, 97 of them are not updated and not returned with the output of the query.
Is there a limit to using OUTPUT or what can be the issue?
public async Task<List<BatchRecord>> GetBatchRecordsAsync(string MW_Ref1)
{
string query = @"
UPDATE MiddlewareRecords
SET ForReuploadFlag = 0,
Rejected = 0,
RejectedRemarks = null,
CurrentStatus = 'Pending'
OUTPUT deleted.*
WHERE MW_Ref1 = @MW_Ref1";
var results = await _connection.QueryAsync<BatchRecord>(query, new { MW_Ref1 }, transaction: _transaction);
return results.ToList();
}
The application is a .NET 6 application using Dapper to execute the query on MS SQL Server DB.
I tried for less records and it works fine. But for these cases the records are not being fully updated, Some of the records are updated and some are not.
WHERE/JOIN(s).CREATE VIEW? Does that have a join in it? maybe the join is many to 1 for some of the rows hence more returned by theSELECTthan affected by theUPDATE