T-SQL script to find the growth size of database files

Below query can be used to see the growth size of database files.

DECLARE @filename NVARCHAR(1000);
DECLARE @bc INT;
DECLARE @ec INT;
DECLARE @bfn VARCHAR(1000);
DECLARE @efn VARCHAR(10);

— Get the name of the current default trace
SELECT @filename = CAST(value AS NVARCHAR(1000))
FROM ::fn_trace_getinfo(DEFAULT)
WHERE traceid = 1 AND property = 2;

— rip apart file name into pieces
SET @filename = REVERSE(@filename);
SET @bc = CHARINDEX(‘.’,@filename);
SET @ec = CHARINDEX(‘_’,@filename)+1;
SET @efn = REVERSE(SUBSTRING(@filename,1,@bc));
SET @bfn = REVERSE(SUBSTRING(@filename,@ec,LEN(@filename)));

— set filename without rollover number
SET @filename = @bfn + @efn

— process all trace files
SELECT 
  ftg.StartTime
,te.name AS EventName
,DB_NAME(ftg.databaseid) AS DatabaseName  
,ftg.Filename
,(ftg.IntegerData*8)/1024.0 AS GrowthMB 
,(ftg.duration/1000)AS DurMS
FROM ::fn_trace_gettable(@filename, DEFAULT) AS ftg 
INNER JOIN sys.trace_events AS te ON ftg.EventClass = te.trace_event_id  
WHERE (ftg.EventClass = 92  — Date File Auto-grow

About vivekjohari

Database Consultant with more than 11.5 years of experience in database designing & programming and DBA related activities.  Had good experience on different databases like SQL Server, MySQL & Oracle, Azure SQL &  Big Data.
This entry was posted in DBA, SQL Advanced, SQL Server and tagged , . Bookmark the permalink.

32 Responses to T-SQL script to find the growth size of database files

  1. Pingback: เลเซอร์ขน

  2. Pingback: mega poker99

  3. Pingback: cornhole boards for sale near me

  4. Pingback: w888

  5. Pingback: botox

  6. Pingback: http://4rent.org.pl/klocki-mega-bloks-minionki-bitwa-na-sniezki-1143.php

  7. Pingback: fun 88

  8. Pingback: sahabatqq

  9. Pingback: ยิงปลา

  10. Pingback: https://biznesblog.biz.pl/forum/marketing-f5/opinie-o-funkymedia-t64.html

  11. Pingback: лазерна епилация на лице цени

  12. Pingback: link nha cai

  13. Pingback: forum

  14. Pingback: cornhole board plans

  15. Pingback: cbd oil tastes like

  16. Pingback: Dream Market Laden

  17. Pingback: Agartha Market

  18. Pingback: Darknet Links

  19. Pingback: Empire Market

  20. Pingback: bai rong ho

  21. Pingback: daftar hondaqq

  22. Pingback: pokermas

  23. Pingback: พนันบอลออนไลน์

  24. Pingback: meja qq

  25. Pingback: cbdque.com

  26. Pingback: site

  27. Pingback: ca do bong bong

  28. Pingback: how to spot fake tag heuer glasses audemars piguet star wheel replica

  29. Pingback: comprar quesos online

  30. Pingback: www.cialisis.org

  31. Pingback: qiuqiu99

  32. Pingback: fowling rules

Leave a Reply