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


Discover more from Technology with Vivek Johari

Subscribe to get the latest posts sent to your email.

32 comments

  1. Pingback: mega poker99
  2. Pingback: w888
  3. Pingback: botox
  4. Pingback: fun 88
  5. Pingback: sahabatqq
  6. Pingback: ยิงปลา
  7. Pingback: link nha cai
  8. Pingback: forum
  9. Pingback: Dream Market Laden
  10. Pingback: Agartha Market
  11. Pingback: Darknet Links
  12. Pingback: Empire Market
  13. Pingback: bai rong ho
  14. Pingback: daftar hondaqq
  15. Pingback: pokermas
  16. Pingback: meja qq
  17. Pingback: cbdque.com
  18. Pingback: site
  19. Pingback: ca do bong bong
  20. Pingback: www.cialisis.org
  21. Pingback: qiuqiu99
  22. Pingback: fowling rules

Leave a Reply