Here is one way:EDIT: Replace <dir> with your directory you want to check on.DECLARE @Foo TABLE (Val NVARCHAR(4000))INSERT @Fooexec xp_cmdshell N'dir "<dir>" /s /-c /a | find "bytes" | find /v "free"'SELECT SUM(CAST(LEFT( SUBSTRING(Val, PATINDEX('%)%', Val) + 1, LEN(Val)) ,LEN(SUBSTRING(Val, PATINDEX('%)%', Val) + 1, LEN(Val))) - 5 )AS BIGINT)) AS TotalBytesFROM @Foo
PS - You may need to enable xp_cmdshellUSE masterGOEXEC sp_configure 'show advanced options', 1;GORECONFIGURE;GOEXEC sp_configure 'xp_cmdshell', 1;GORECONFIGURE;