<p>I need to know how much space occupies all the databases inside an SQL Server 2000. I did some research but could not found any script to help me out.</p>

[{'answer_id': 12911, 'author': 'UnkwnTech', 'author_id': 115, 'author_profile': 'https://Stackoverflow.com/users/115', 'pm_score': 0, 'selected': False, 'text': '<p>I know this might sound a little arcanine but why not just stat the directory that contains the database.</p>\n'}, {'answer_id': 12915, 'author': 'Jon Galloway', 'author_id': 5, 'author_profile': 'https://Stackoverflow.com/users/5', 'pm_score': 4, 'selected': True, 'text': '<p>Source: <a href="http://searchsqlserver.techtarget.com/tip/0,289483,sid87_gci1313431,00.html" rel="noreferrer">http://searchsqlserver.techtarget.com/tip/0,289483,sid87_gci1313431,00.html</a>\nWorks with SQL2000,2005,2008</p>\n\n<pre><code>USE master;\nGO\n\nIF OBJECT_ID(\'dbo.sp_SDS\', \'P\') IS NOT NULL\n  DROP PROCEDURE dbo.sp_SDS;\nGO\n\nCREATE PROCEDURE dbo.sp_SDS \n  @TargetDatabase sysname = NULL,     --  NULL: all dbs\n  @Level varchar(10) = \'Database\',    --  or "File"\n  @UpdateUsage bit = 0,               --  default no update\n  @Unit char(2) = \'MB\'                --  Megabytes, Kilobytes or Gigabytes\nAS\n\n/**************************************************************************************************\n**\n**  author: Richard Ding\n**  date:   4/8/2008\n**  usage:  list db size AND path w/o SUMmary\n**  test code: sp_SDS   --  default behavior\n**             sp_SDS \'maAster\'\n**             sp_SDS NULL, NULL, 0\n**             sp_SDS NULL, \'file\', 1, \'GB\'\n**             sp_SDS \'Test_snapshot\', \'Database\', 1\n**             sp_SDS \'Test\', \'File\', 0, \'kb\'\n**             sp_SDS \'pfaids\', \'Database\', 0, \'gb\'\n**             sp_SDS \'tempdb\', NULL, 1, \'kb\'\n**   \n**************************************************************************************************/\n\nSET NOCOUNT ON;\n\nIF @TargetDatabase IS NOT NULL AND DB_ID(@TargetDatabase) IS NULL\n  BEGIN\n    RAISERROR(15010, -1, -1, @TargetDatabase);\n    RETURN (-1)\n  END\n\nIF OBJECT_ID(\'tempdb.dbo.##Tbl_CombinedInfo\', \'U\') IS NOT NULL\n  DROP TABLE dbo.##Tbl_CombinedInfo;\n\nIF OBJECT_ID(\'tempdb.dbo.##Tbl_DbFileStats\', \'U\') IS NOT NULL\n  DROP TABLE dbo.##Tbl_DbFileStats;\n\nIF OBJECT_ID(\'tempdb.dbo.##Tbl_ValidDbs\', \'U\') IS NOT NULL\n  DROP TABLE dbo.##Tbl_ValidDbs;\n\nIF OBJECT_ID(\'tempdb.dbo.##Tbl_Logs\', \'U\') IS NOT NULL\n  DROP TABLE dbo.##Tbl_Logs;\n\nCREATE TABLE dbo.##Tbl_CombinedInfo (\n  DatabaseName sysname NULL, \n  [type] VARCHAR(10) NULL, \n  LogicalName sysname NULL,\n  T dec(10, 2) NULL,\n  U dec(10, 2) NULL,\n  [U(%)] dec(5, 2) NULL,\n  F dec(10, 2) NULL,\n  [F(%)] dec(5, 2) NULL,\n  PhysicalName sysname NULL );\n\nCREATE TABLE dbo.##Tbl_DbFileStats (\n  Id int identity, \n  DatabaseName sysname NULL, \n  FileId int NULL, \n  FileGroup int NULL, \n  TotalExtents bigint NULL, \n  UsedExtents bigint NULL, \n  Name sysname NULL, \n  FileName varchar(255) NULL );\n\nCREATE TABLE dbo.##Tbl_ValidDbs (\n  Id int identity, \n  Dbname sysname NULL );\n\nCREATE TABLE dbo.##Tbl_Logs (\n  DatabaseName sysname NULL, \n  LogSize dec (10, 2) NULL, \n  LogSpaceUsedPercent dec (5, 2) NULL,\n  Status int NULL );\n\nDECLARE @Ver varchar(10), \n        @DatabaseName sysname, \n        @Ident_last int, \n        @String varchar(2000),\n        @BaseString varchar(2000);\n\nSELECT @DatabaseName = \'\', \n       @Ident_last = 0, \n       @String = \'\', \n       @Ver = CASE WHEN @@VERSION LIKE \'%9.0%\' THEN \'SQL 2005\' \n                   WHEN @@VERSION LIKE \'%8.0%\' THEN \'SQL 2000\' \n                   WHEN @@VERSION LIKE \'%10.0%\' THEN \'SQL 2008\' \n              END;\n\nSELECT @BaseString = \n\' SELECT DB_NAME(), \' + \nCASE WHEN @Ver = \'SQL 2000\' THEN \'CASE WHEN status &amp; 0x40 = 0x40 THEN \'\'Log\'\'  ELSE \'\'Data\'\' END\' \n  ELSE \' CASE type WHEN 0 THEN \'\'Data\'\' WHEN 1 THEN \'\'Log\'\' WHEN 4 THEN \'\'Full-text\'\' ELSE \'\'reserved\'\' END\' END + \n\', name, \' + \nCASE WHEN @Ver = \'SQL 2000\' THEN \'filename\' ELSE \'physical_name\' END + \n\', size*8.0/1024.0 FROM \' + \nCASE WHEN @Ver = \'SQL 2000\' THEN \'sysfiles\' ELSE \'sys.database_files\' END + \n\' WHERE \'\n+ CASE WHEN @Ver = \'SQL 2000\' THEN \' HAS_DBACCESS(DB_NAME()) = 1\' ELSE \'state_desc = \'\'ONLINE\'\'\' END + \'\';\n\nSELECT @String = \'INSERT INTO dbo.##Tbl_ValidDbs SELECT name FROM \' + \n                 CASE WHEN @Ver = \'SQL 2000\' THEN \'master.dbo.sysdatabases\' \n                      WHEN @Ver IN (\'SQL 2005\', \'SQL 2008\') THEN \'master.sys.databases\' \n                 END + \' WHERE HAS_DBACCESS(name) = 1 ORDER BY name ASC\';\nEXEC (@String);\n\nINSERT INTO dbo.##Tbl_Logs EXEC (\'DBCC SQLPERF (LOGSPACE) WITH NO_INFOMSGS\');\n\n--  For data part\nIF @TargetDatabase IS NOT NULL\n  BEGIN\n    SELECT @DatabaseName = @TargetDatabase;\n    IF @UpdateUsage &lt;&gt; 0 AND DATABASEPROPERTYEX (@DatabaseName,\'Status\') = \'ONLINE\' \n          AND DATABASEPROPERTYEX (@DatabaseName, \'Updateability\') &lt;&gt; \'READ_ONLY\'\n      BEGIN\n        SELECT @String = \'USE [\' + @DatabaseName + \'] DBCC UPDATEUSAGE (0)\';\n        PRINT \'*** \' + @String + \' *** \';\n        EXEC (@String);\n        PRINT \'\';\n      END\n\n    SELECT @String = \'INSERT INTO dbo.##Tbl_CombinedInfo (DatabaseName, type, LogicalName, PhysicalName, T) \' + @BaseString; \n\n    INSERT INTO dbo.##Tbl_DbFileStats (FileId, FileGroup, TotalExtents, UsedExtents, Name, FileName)\n          EXEC (\'USE [\' + @DatabaseName + \'] DBCC SHOWFILESTATS WITH NO_INFOMSGS\');\n    EXEC (\'USE [\' + @DatabaseName + \'] \' + @String);\n\n    UPDATE dbo.##Tbl_DbFileStats SET DatabaseName = @DatabaseName; \n  END\nELSE\n  BEGIN\n    WHILE 1 = 1\n      BEGIN\n        SELECT TOP 1 @DatabaseName = Dbname FROM dbo.##Tbl_ValidDbs WHERE Dbname &gt; @DatabaseName ORDER BY Dbname ASC;\n        IF @@ROWCOUNT = 0\n          BREAK;\n        IF @UpdateUsage &lt;&gt; 0 AND DATABASEPROPERTYEX (@DatabaseName, \'Status\') = \'ONLINE\' \n              AND DATABASEPROPERTYEX (@DatabaseName, \'Updateability\') &lt;&gt; \'READ_ONLY\'\n          BEGIN\n            SELECT @String = \'DBCC UPDATEUSAGE (\'\'\' + @DatabaseName + \'\'\') \';\n            PRINT \'*** \' + @String + \'*** \';\n            EXEC (@String);\n            PRINT \'\';\n          END\n\n        SELECT @Ident_last = ISNULL(MAX(Id), 0) FROM dbo.##Tbl_DbFileStats;\n\n        SELECT @String = \'INSERT INTO dbo.##Tbl_CombinedInfo (DatabaseName, type, LogicalName, PhysicalName, T) \' + @BaseString; \n\n        EXEC (\'USE [\' + @DatabaseName + \'] \' + @String);\n\n        INSERT INTO dbo.##Tbl_DbFileStats (FileId, FileGroup, TotalExtents, UsedExtents, Name, FileName)\n          EXEC (\'USE [\' + @DatabaseName + \'] DBCC SHOWFILESTATS WITH NO_INFOMSGS\');\n\n        UPDATE dbo.##Tbl_DbFileStats SET DatabaseName = @DatabaseName WHERE Id BETWEEN @Ident_last + 1 AND @@IDENTITY;\n      END\n  END\n\n--  set used size for data files, do not change total obtained from sys.database_files as it has for log files\nUPDATE dbo.##Tbl_CombinedInfo \nSET U = s.UsedExtents*8*8/1024.0 \nFROM dbo.##Tbl_CombinedInfo t JOIN dbo.##Tbl_DbFileStats s \nON t.LogicalName = s.Name AND s.DatabaseName = t.DatabaseName;\n\n--  set used size and % values for log files:\nUPDATE dbo.##Tbl_CombinedInfo \nSET [U(%)] = LogSpaceUsedPercent, \nU = T * LogSpaceUsedPercent/100.0\nFROM dbo.##Tbl_CombinedInfo t JOIN dbo.##Tbl_Logs l \nON l.DatabaseName = t.DatabaseName \nWHERE t.type = \'Log\';\n\nUPDATE dbo.##Tbl_CombinedInfo SET F = T - U, [U(%)] = U*100.0/T;\n\nUPDATE dbo.##Tbl_CombinedInfo SET [F(%)] = F*100.0/T;\n\nIF UPPER(ISNULL(@Level, \'DATABASE\')) = \'FILE\'\n  BEGIN\n    IF @Unit = \'KB\'\n      UPDATE dbo.##Tbl_CombinedInfo\n      SET T = T * 1024, U = U * 1024, F = F * 1024;\n\n    IF @Unit = \'GB\'\n      UPDATE dbo.##Tbl_CombinedInfo\n      SET T = T / 1024, U = U / 1024, F = F / 1024;\n\n    SELECT DatabaseName AS \'Database\',\n      type AS \'Type\',\n      LogicalName,\n      T AS \'Total\',\n      U AS \'Used\',\n      [U(%)] AS \'Used (%)\',\n      F AS \'Free\',\n      [F(%)] AS \'Free (%)\',\n      PhysicalName\n      FROM dbo.##Tbl_CombinedInfo \n      WHERE DatabaseName LIKE ISNULL(@TargetDatabase, \'%\') \n      ORDER BY DatabaseName ASC, type ASC;\n\n    SELECT CASE WHEN @Unit = \'GB\' THEN \'GB\' WHEN @Unit = \'KB\' THEN \'KB\' ELSE \'MB\' END AS \'SUM\',\n        SUM (T) AS \'TOTAL\', SUM (U) AS \'USED\', SUM (F) AS \'FREE\' FROM dbo.##Tbl_CombinedInfo;\n  END\n\nIF UPPER(ISNULL(@Level, \'DATABASE\')) = \'DATABASE\'\n  BEGIN\n    DECLARE @Tbl_Final TABLE (\n      DatabaseName sysname NULL,\n      TOTAL dec (10, 2),\n      [=] char(1),\n      used dec (10, 2),\n      [used (%)] dec (5, 2),\n      [+] char(1),\n      free dec (10, 2),\n      [free (%)] dec (5, 2),\n      [==] char(2),\n      Data dec (10, 2),\n      Data_Used dec (10, 2),\n      [Data_Used (%)] dec (5, 2),\n      Data_Free dec (10, 2),\n      [Data_Free (%)] dec (5, 2),\n      [++] char(2),\n      Log dec (10, 2),\n      Log_Used dec (10, 2),\n      [Log_Used (%)] dec (5, 2),\n      Log_Free dec (10, 2),\n      [Log_Free (%)] dec (5, 2) );\n\n    INSERT INTO @Tbl_Final\n      SELECT x.DatabaseName, \n           x.Data + y.Log AS \'TOTAL\', \n           \'=\' AS \'=\', \n           x.Data_Used + y.Log_Used AS \'U\',\n           (x.Data_Used + y.Log_Used)*100.0 / (x.Data + y.Log)  AS \'U(%)\',\n           \'+\' AS \'+\',\n           x.Data_Free + y.Log_Free AS \'F\',\n           (x.Data_Free + y.Log_Free)*100.0 / (x.Data + y.Log)  AS \'F(%)\',\n           \'==\' AS \'==\',\n           x.Data, \n           x.Data_Used, \n           x.Data_Used*100/x.Data AS \'D_U(%)\',\n           x.Data_Free, \n           x.Data_Free*100/x.Data AS \'D_F(%)\',\n           \'++\' AS \'++\', \n           y.Log, \n           y.Log_Used, \n           y.Log_Used*100/y.Log AS \'L_U(%)\',\n           y.Log_Free, \n           y.Log_Free*100/y.Log AS \'L_F(%)\'\n      FROM \n      ( SELECT d.DatabaseName, \n               SUM(d.T) AS \'Data\', \n               SUM(d.U) AS \'Data_Used\', \n               SUM(d.F) AS \'Data_Free\' \n          FROM dbo.##Tbl_CombinedInfo d WHERE d.type = \'Data\' GROUP BY d.DatabaseName ) AS x\n      JOIN \n      ( SELECT l.DatabaseName, \n               SUM(l.T) AS \'Log\', \n               SUM(l.U) AS \'Log_Used\', \n               SUM(l.F) AS \'Log_Free\' \n          FROM dbo.##Tbl_CombinedInfo l WHERE l.type = \'Log\' GROUP BY l.DatabaseName ) AS y\n      ON x.DatabaseName = y.DatabaseName;\n\n    IF @Unit = \'KB\'\n      UPDATE @Tbl_Final SET TOTAL = TOTAL * 1024,\n      used = used * 1024,\n      free = free * 1024,\n      Data = Data * 1024,\n      Data_Used = Data_Used * 1024,\n      Data_Free = Data_Free * 1024,\n      Log = Log * 1024,\n      Log_Used = Log_Used * 1024,\n      Log_Free = Log_Free * 1024;\n\n     IF @Unit = \'GB\'\n      UPDATE @Tbl_Final SET TOTAL = TOTAL / 1024,\n      used = used / 1024,\n      free = free / 1024,\n      Data = Data / 1024,\n      Data_Used = Data_Used / 1024,\n      Data_Free = Data_Free / 1024,\n      Log = Log / 1024,\n      Log_Used = Log_Used / 1024,\n      Log_Free = Log_Free / 1024;\n\n      DECLARE @GrantTotal dec(11, 2);\n      SELECT @GrantTotal = SUM(TOTAL) FROM @Tbl_Final;\n\n      SELECT \n      CONVERT(dec(10, 2), TOTAL*100.0/@GrantTotal) AS \'WEIGHT (%)\', \n      DatabaseName AS \'DATABASE\',\n      CONVERT(VARCHAR(12), used) + \'  (\' + CONVERT(VARCHAR(12), [used (%)]) + \' %)\' AS \'USED  (%)\',\n      [+],\n      CONVERT(VARCHAR(12), free) + \'  (\' + CONVERT(VARCHAR(12), [free (%)]) + \' %)\' AS \'FREE  (%)\',\n      [=],\n      TOTAL, \n      [=],\n      CONVERT(VARCHAR(12), Data) + \'  (\' + CONVERT(VARCHAR(12), Data_Used) + \',  \' + \n      CONVERT(VARCHAR(12), [Data_Used (%)]) + \'%)\' AS \'DATA  (used,  %)\',\n      [+],\n      CONVERT(VARCHAR(12), Log) + \'  (\' + CONVERT(VARCHAR(12), Log_Used) + \',  \' + \n      CONVERT(VARCHAR(12), [Log_Used (%)]) + \'%)\' AS \'LOG  (used,  %)\'\n        FROM @Tbl_Final \n        WHERE DatabaseName LIKE ISNULL(@TargetDatabase, \'%\')\n        ORDER BY DatabaseName ASC;\n\n    IF @TargetDatabase IS NULL\n      SELECT CASE WHEN @Unit = \'GB\' THEN \'GB\' WHEN @Unit = \'KB\' THEN \'KB\' ELSE \'MB\' END AS \'SUM\', \n      SUM (used) AS \'USED\', \n      SUM (free) AS \'FREE\', \n      SUM (TOTAL) AS \'TOTAL\', \n      SUM (Data) AS \'DATA\', \n      SUM (Log) AS \'LOG\' \n      FROM @Tbl_Final;\n  END\n\nRETURN (0)\n\nGO\n</code></pre>\n'}, {'answer_id': 4676585, 'author': 'Aaron Kempf', 'author_id': 565882, 'author_profile': 'https://Stackoverflow.com/users/565882', 'pm_score': 0, 'selected': False, 'text': '<p>if you use SQL Server Management Studio (from SQL 2005 or newer) you can just right-click properties on the database itself, and then click on the storage tab.</p>\n'}]
['https://Stackoverflow.com/questions/12906', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/296/']