Tuesday, October 30, 2012

Sql Server All Database Used Space ,Size Info..... Using MSForeachdb

Sql Server All Database Used Space ,Size Info.... Using MSForeachdb

EXEC sp_MSforeachdb 'USE [?]SELECT
A.FILEID,
[FILE_SIZE_MB] =
CONVERT(DECIMAL(12,2),ROUND(A.size/128.000,2)),
[SPACE_USED_MB] =
CONVERT(DECIMAL(12,2),ROUND(FILEPROPERTY(A.name,''SpaceUsed'')/128.000,2)),
[FREE_SPACE_MB] =
CONVERT(DECIMAL(12,2),ROUND((A.SIZE-FILEPROPERTY(A.name,''SpaceUsed''))/128.000,2)) ,
NAME = left(A.NAME,15),
FILENAME =RIGHT(A.FILENAME,CHARINDEX(''\'', REVERSE(A.FILENAME))-1)
FROM
dbo.SYSFILES A'