The data type of DATABASE_SIZE in the output of sp_databases is int. The biggest number of int is 2,147,483,647. If the database size is over 2.15TB, it can not be displayed. That might be the reason why it is NULL.
stored proceduce sp_databases is returning Null value for larger databases
Stored Procedure sp_databases returns database size as Null when database size is in Terabytes. Please find below the result of the stored procedure execution in one of my instance where database size is 6TB.
Developer technologies | Transact-SQL
SQL Server | Other
3 additional answers
Sort by: Most helpful
-
Tom Phillips 17,771 Reputation points
2021-04-14T18:23:28.023+00:00 -
MelissaMa-MSFT 24,221 Reputation points
2021-04-15T03:19:40.443+00:00 Hi @Subodh Agnihotri ,
Welcome to Microsoft Q&A!
Agreed with Guoxiong, in official document sp_databases as below:
Column name |Data type |Description
DATABASE_SIZE |int |Size of database, in kilobytesThen the maximum of database size could be shown is 2147483647(KB)/1024/1024
=2047(GB)~2(TB) which is much smaller than 6TB as you mentioned. So it would show as NULL.Best regards
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. -
Subodh Agnihotri 21 Reputation points
2021-04-16T09:09:18.543+00:00 Thanks everyone for helping me out here. I extracted the query used by stored procedure and modified it to convert the size to numeric instead of int.