# Database Discussions > MS SQL Server 7/MS SQL Server 2000 >  Arithmetic overflow error converting expression to data type int.

## nathan

l&#39;m running this procedure and l get this error. All l&#39;m trying to do is to get the size of the database and its objects and what the size should be so that its sized right. Is there a better way of doing this ?

CREATE PROCEDURE sp_totalsize as

SELECT o.name &#39;Table&#39;, SUM(c.length) &#39;Record size&#39;,
MAX (i.rows) &#39;#of rows&#39;,
CONVERT (decimal (10, 4), SUM (c.length * i.rows)/(1024.00 * 1024.00)) &#39;Approx. size (MB)&#39;

FROM sysobjects o, syscolumns c, sysindexes i
WHERE o.id = c.id
AND o.id = i.id
AND (i.indid = 1 or i.indid = 0)
AND o.type = &#39;U&#39;
GROUP BY o.name
COMPUTE SUM (CONVERT (decimal (10,4), SUM (c.length * i.rows)/(1024.00 * 1024.00))) 


GO




(17 row(s) affected)

Server: Msg 8115, Level 16, State 2, Procedure sp_totalsize, Line 3
Arithmetic overflow error converting expression to data type int.

----------


## Markus

Hi Nathan,

first of all, I don&#39;t know why you get the error message, because in my case it works fine.
But looking at your problem sizing the database Iwouldn&#39;t use this script anyway, because the results are not really what you want. I ran the script on a database of 1,6GB and the result of the query was just 280 MB. The reason for the difference is that the script doesn&#39;t look at the size of indexes and especially if your having image or text columns, only the 16 byte are counted but not the real datasize.

Try using sp_MStablespace which gives a better indication of the tablesize. I know it doesn&#39;t give you all the tables at once but in combination with sp_MSforeachtable you can get a good overview.

Markus


------------
nathan at 8/28/2002 4:02:21 AM

l&#39;m running this procedure and l get this error. All l&#39;m trying to do is to get the size of the database and its objects and what the size should be so that its sized right. Is there a better way of doing this ?

CREATE PROCEDURE sp_totalsize as

SELECT o.name &#39;Table&#39;, SUM(c.length) &#39;Record size&#39;,
MAX (i.rows) &#39;#of rows&#39;,
CONVERT (decimal (10, 4), SUM (c.length * i.rows)/(1024.00 * 1024.00)) &#39;Approx. size (MB)&#39;

FROM sysobjects o, syscolumns c, sysindexes i
WHERE o.id = c.id
AND o.id = i.id
AND (i.indid = 1 or i.indid = 0)
AND o.type = &#39;U&#39;
GROUP BY o.name
COMPUTE SUM (CONVERT (decimal (10,4), SUM (c.length * i.rows)/(1024.00 * 1024.00))) 


GO




(17 row(s) affected)

Server: Msg 8115, Level 16, State 2, Procedure sp_totalsize, Line 3
Arithmetic overflow error converting expression to data type int.

----------

