数据库大小(报表用)
-- 数据库大小
CREATE TABLE #tmptb(NAME VARCHAR(100),db_size VARCHAR(100),
OWNER VARCHAR(500),dbid INT,created DATE,STATUS VARCHAR (500),
COMPATIBILITY_LEVEL INT,FILENAME VARCHAR(500))
INSERT INTO #tmptb(name,db_size,OWNER,dbid,created,STATUS,COMPATIBILITY_LEVEL)
EXEC sp_helpdb
UPDATE #tmptb SET FILENAME = b.FILENAME
FROM #tmptb a INNER JOIN master.dbo.sysdatabases b ON a.dbid = b.dbid
SELECT name,db_size FROM #tmptb where dbid >= 5 order by db_size desc
DROP TABLE #tmptb