我试图得到一个列,但是当我运行这个查询我得到以下错误.任何建议?
SELECT SUM(Size) as total FROM AllDocs Where DirName LIKE 'sites/test/test%' ERROR: Msg 8115,Level 16,State 2,Line 1 Arithmetic overflow error converting expression to data type int. Warning: Null value is eliminated by an aggregate or other SET operation.
解决方法
虽然所有的尺寸都可以适应于INT(最多2 ^ 31 – 1),但它们的SUM不能.
把它们变成BIGINT:
SELECT SUM(CAST(Size AS BIGINT)) as total FROM AllDocs WHERE DirName LIKE 'sites/test/test%'