Arithmetic overflow error converting expression to data type int.

While trying to execute the below TSQL query I got the following error message:

SELECT SUM(size*8)
FROM master.sys.master_files

SERVERNAME(User): Msg 8115, Level 16, State 2, Line 1
Arithmetic overflow error converting expression to data type int.

I gathered that I was receiving this error message because the SUM of the SQL Server database files was larger than the maximum range of the INT data type (range maxes out at 2,147,483,647).

To resolve this issue I converted the size column to a BIGINT, TSQL query below:

SELECT SUM(CAST(size*8 AS BIGINT))
FROM master.sys.master_files

Leave a Reply

Your email address will not be published. Required fields are marked *