Has anyone seen where subqueries collapse into a sum? I have code like the following, which has been running fine for over a year:
UPDATE Reports..DataStats
SET Vendors_Cnt = (SELECT COUNT(*) FROM vVendors__AllRecords),
Vendors_Audit_Cnt = (SELECT COUNT(*) FROM vVendors_InvAudit),
Vendors_Rpts_Cnt = (SELECT COUNT(*) FROM vVendors_Inv12mo),
Vendors_InvUnused = (SELECT COUNT(*) FROM vVendors_InvUnused),
Vendors_InvOne = (SELECT COUNT(*) FROM vVendors_InvOne),
Vendors_InvMulti = (SELECT COUNT(*) FROM vVendors_InvMulti),
Vendors_InvUnpaid = (SELECT COUNT(*) FROM vVendors_InvUnpaid),
Vendors_InvNewer = (SELECT COUNT(*) FROM vVendors_InvNewer),
Vendors_Inv12mo = (SELECT COUNT(*) FROM vVendors_Inv12mo),
Vendors_InvPrior = (SELECT COUNT(*) FROM vVendors_InvPrior),
Vendors_InvSkipYear = (SELECT COUNT(*) FROM vVendors_InvSkipYear),
Vendors_Known = (SELECT COUNT(*) FROM vVendors_Known),
Vendors_Orphaned = (SELECT COUNT(*) FROM vVendors_Orphaned),
Vendors_Active = (SELECT COUNT(*) FROM vVendors_Active),
Vendors_Inactive = (SELECT COUNT(*) FROM vVendors_Inactive),
Vendors_Excluded = (SELECT COUNT(*) FROM vVendors_Excluded)
WHERE (AuditName = @.AuditName)
But now it is generating overflows...and is not equivalent to (ignoring the obvious UPDATE vs. return differences for illustration):
SELECT COUNT(*) FROM vVendors__AllRecords
SELECT COUNT(*) FROM vVendors_InvAudit
SELECT COUNT(*) FROM vVendors_Inv12mo
SELECT COUNT(*) FROM vVendors_InvUnused
SELECT COUNT(*) FROM vVendors_InvOne
SELECT COUNT(*) FROM vVendors_InvMulti
SELECT COUNT(*) FROM vVendors_InvUnpaid
SELECT COUNT(*) FROM vVendors_InvNewer
SELECT COUNT(*) FROM vVendors_Inv12mo
SELECT COUNT(*) FROM vVendors_InvPrior
SELECT COUNT(*) FROM vVendors_InvSkipYear
SELECT COUNT(*) FROM vVendors_Known
SELECT COUNT(*) FROM vVendors_Orphaned
SELECT COUNT(*) FROM vVendors_Active
SELECT COUNT(*) FROM vVendors_Inactive
SELECT COUNT(*) FROM vVendors_Excluded
This appears to have started around the beginning of May. Anyone else suffer after patches?
http://www.akadia.com/services/dealing_with_null_values.html|||How high do those counts go? What are the datatypes for thosecolumns storing the counts? Have you exceeded the integer limitof 2,147,483,647?|||The failed SUM appears to be 44 million. The correct values should each be under 100 thousand. Really wierd!|||Try SELECT SUM instead of COUNT(*) see if it makes a difference. Hope this helps.|||
RLyda wrote: The failed SUM appears to be 44 million. Thecorrect values should each be under 100 thousand. Reallywierd!
What is the data type for, say, the Vendors_Audit_Cntcolumn?sql
No comments:
Post a Comment