#_filename# has #qmd_sheet.recordCount# records

SELECT assignedContractNbr, count(distinct assignedContractNbr) AS cnt FROM qmd_sheet GROUP BY assignedContractNbr
#_filename# has #qmd_distinctContractsOnSheet.recordCount# distinct contracts

SELECT c.assignedContractNbr ,r.volumeGenerator ,r.requestId FROM tbl_TPM_Contracts AS c WITH (nolock) INNER JOIN tbl_TPM_Requests AS r WITH (nolock) ON c.ownerType = r.ownerType AND c.ownerId = r.ownerId AND c.assignedContractNbr = r.assignedContractNbr WHERE c.ownerType = AND c.ownerId = AND c.assignedContractNbr IN () SELECT DISTINCT assignedContractNbr FROM qmd_findExisting
Found #qmd_distinctContractsFound.recordCount#/#qmd_distinctContractsOnSheet.recordCount# matching contracts in the database.

Found #qmd_findExisting.recordCount# matching sub-contracts in the database.

Cannot find the following contracts:

#qmd_distinctContractsOnSheet.assignedContractNbr#

SELECT * FROM qmd_findExisting WHERE volumeGenerator = 'Y'
#qmd_existingVolumeGenerator.recordCount# subcontracts are already count-cases.

#qmd_existingVolumeGenerator.assignedContractNbr# (subcontractId: #qmd_existingVolumeGenerator.requestId#)

SELECT * FROM qmd_findExisting WHERE volumeGenerator <> 'Y'
#qmd_existingNonVolumeGenerator.recordCount# sub-contracts are going to be updated to count-cases.

#qmd_existingNonVolumeGenerator.assignedContractNbr# (subcontractId: #qmd_existingNonVolumeGenerator.requestId#)

UPDATE tbl_TPM_Contracts SET flaggedForRecalc = 'Y' ,flaggedForRecalcTime = GETDATE() WHERE ownerType = AND ownerId = AND assignedContractNbr IN ()
Updated #updateResult.recordCount# contract records

UPDATE tbl_TPM_Requests SET volumeGenerator = 'Y' WHERE ownerType = AND ownerId = AND requestId IN () AND volumeGenerator <> 'Y'
Updated #updateResult.recordCount# sub-contract records