Hi John,
Thank you very much!! 🙂 I made this one. 🙂
Create table #DInfo([DDrive] nChar(1) Null, [MB_Free] Float Null)
Insert #DInfo EXEC master..xp_fixeddrives
DECLARE @vDBName nVarchar(200)
DECLARE @vSTR nVarchar(4000)
DECLARE InvDBs CURSOR FOR
SELECT rtrim(ltrim(NAME))
FROM dbo.sysdatabases d
OPEN InvDBs
FETCH InvDBs into @vDBName
WHILE @@FETCH_STATUS = 0
BEGIN
SET @vSTR = 'USE ' + QUOTENAME(@vDBName) + CHAR(10)
SET @vSTR = @vSTR + '
SELECT
convert(nvarchar(128), serverproperty(''ServerName'')) As ''Server Name'',
DB_NAME() As ''DB Name'',
Case when SUBSTRING(a.filename,LEN(a.filename) -2,3) = ''mdf'' then ''Data'' else ''Log'' end As ''File Type'',
convert(decimal(12,2),round(a.size/128.000,2)) as file_size,
a.filename As ''File Name'',
Substring(a.filename,1,1) As ''Disk Drive'',
c.MB_Free As ''Drive Free Space (MB)'',
@@Version As ''SQLVersion''
FROM dbo.sysfiles a LEFT OUTER JOIN dbo.sysfilegroups b
ON a.groupid = b.groupid
INNER JOIN #DInfo c on Substring(a.filename,1,1) = c.DDrive
'
EXEC (@vSTR)
FETCH InvDBs into @vDBName
END
CLOSE InvDBs
DEALLOCATE InvDBs
DROP TABLE #DInfo
Tsinelas