Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
dewacorp.alliances
452 Posts |
Posted - 2006-12-07 : 23:33:23
|
quote: DECLARE @SQL NVARCHAR(4000) DECLARE @dbid INT DECLARE @DBName SYSNAMESET @dbid = 0 CREATE TABLE #tmpFileList ( DB_File_Name nvarchar(100), Size_MB decimal(10,2), Used_MB decimal(10,2) ) WHILE @dbid < (SELECT MAX(dbid) FROM master.dbo.sysdatabases) BEGIN SELECT TOP 1 @dbid = dbid, @DBName = name FROM master.dbo.sysdatabases WHERE dbid > @dbid ORDER BY dbid SET @SQL = 'INSERT INTO #tmpFileList ' + 'select [DB_File_Name] = convert(nvarchar(40),Name), [Size_MB] = convert(decimal(10,2),round(size/128.0000,2)), ' + '[Used_MB] = convert(decimal(10,2), round(fileproperty(name,''SpaceUsed'')/128.0000,2)) '+ 'from [' + @DBName + '].dbo.sysfiles order by fileid' PRINT @SQL EXEC sp_executesql @statement = @SQL END select * from #tmpFileListdrop table #tmpFileList
Hi all ... I am creating a script for getting the list of the size each database including used space.I notice that when I used fileproperty(name,''SpaceUsed''), it returns null. But if I'm using USE xxx and then run this scipt returns a size. Any ideas |
|
Kristen
Test
22859 Posts |
|
dewacorp.alliances
452 Posts |
Posted - 2006-12-08 : 14:24:27
|
Thanks Kirsten.But I still want to get TLOG size (used space and unused space) which is not provided on those scripts. |
 |
|
|
|
|
|
|