March 27, 2008 at 10:23 am
Hello,
Is there a way, by either looking in a log file or through T-SQL, to tell if a database has grown and, if so, when it happened? I can't seem to find anything pointing me in this direction, but I figured I'd throw it out here and see if anyone had any answers or advice. Thanks once again.
March 27, 2008 at 11:10 am
I just checked the SQL Log File Viewer, and I see auto grows being logged..
Is this what you are looking for?
-- Cory
March 27, 2008 at 11:22 am
I reckon that's it. Thank you Cory! Do you know if this information might also be stored in a system table somewhere?
March 27, 2008 at 11:29 am
I am fairly sure the answer is no. the log files are located ..\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG. I think there are ways to query these log files, but, I dont know them atm.
-- Cory
March 27, 2008 at 11:32 am
Ok. Thanks again, Cory.
March 31, 2008 at 12:17 pm
EXEC sp_track_db_growth
GO
March 31, 2008 at 12:22 pm
Babu_Raj (3/31/2008)
EXEC sp_track_db_growthGO
Usually, there needs to be an existing SP prior to running a SP:cool:. sp_track_db_growth is not a SP that exists. Perhaps you would be kind enough to post the SP you have created? 🙂
-- Cory
March 31, 2008 at 2:29 pm
I personally don't care when it happened, I just want to know it happened. On a weekly basis I run the following. It stores the data for me in a table and I check my data from time to time. It's great to use the metrics to "forecast" disk space needs.
CREATE PROCEDURE usp_DB_SpacedUsed AS
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
-- Declare local variables
EXEC master..sp_MSForeachdb '
USE [?]IF DB_ID(''?'')>4
BEGIN
insert into DBMaint..DBSizeUsed
SELECT name AS [File], filename as File_Name
, CAST(size/128.0 as DECIMAL(10,2)) AS Size_in_MB
, CAST(FILEPROPERTY(name, ''SpaceUsed'')/128.0 as DECIMAL(10,2)) as Space_Used
, CAST(size/128.0-(FILEPROPERTY(name, ''SpaceUsed'')/128.0) AS DECIMAL(10,2)) AS Available_Space
, getdate() as RunDate
FROM SYSFILES
--BEGIN
--PRINT ''?''
--END
END'
GO
-- You can't be late until you show up.
March 31, 2008 at 5:06 pm
Babu_Raj (3/31/2008)
EXEC sp_track_db_growthGO
I agree... such a sproc is NOT provided by MS in any installation of SQL Server 2000... would you post the code for this sp_track_db_growth sproc that you use?
--Jeff Moden
Change is inevitable... Change for the better is not.
March 31, 2008 at 5:28 pm
March 31, 2008 at 6:13 pm
Thanks, Brian...
Just so everyone knows, sp_track_db_growth does not even come close to what the OP asked for. Rather, it tracks what size the backup files are. It does not detect when a DB growth has occured nor does it figure out the true size of the DB.
For example, try running it against TempDB and see what happens. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
March 31, 2008 at 6:40 pm
Cory Ellingson (3/27/2008)
I just checked the SQL Log File Viewer, and I see auto grows being logged..Is this what you are looking for?
Cory... I've not had to use the SQL Log File Viewer before... I've had to use the Error log before. Are they the same? If not, how do I get to the SQL Log File Viewer you spoke of in SQL Server 2000 and 2005?
Thanks...
--Jeff Moden
Change is inevitable... Change for the better is not.
March 31, 2008 at 7:04 pm
Jeff Moden (3/31/2008)
Cory... I've not had to use the SQL Log File Viewer before... I've had to use the Error log before. Are they the same? If not, how do I get to the SQL Log File Viewer you spoke of in SQL Server 2000 and 2005?Thanks...
Hey Jeff -
thanks for asking, and pointing out that maybe some may not know what I was talking about. In both SQL 2000 and SQL 2005 SSMS, there is a SQL Server Logs stored under "Management" -> "SQL Server Logs". In these, there are events such as DB growth happening. There are ways to use some sort of viewer to read these, or you can use the SSMS tool.
Let me know if any one has trouble finding this.
PS - Thanks Jeff - I am not sure if you were prodding me to learn by teaching, or what, but thank you. 🙂
-- Cory
March 31, 2008 at 7:08 pm
I found this article from our very own Brian Knight.
http://www.sqlservercentral.com/articles/Administering/readpurgelog/279/
-- Cory
March 31, 2008 at 7:12 pm
Jeff Moden (3/31/2008)
Thanks, Brian...Just so everyone knows, sp_track_db_growth does not even come close to what the OP asked for. Rather, it tracks what size the backup files are. It does not detect when a DB growth has occured nor does it figure out the true size of the DB.
For example, try running it against TempDB and see what happens. 😉
True, but it's not unusual to track backup sizes as a reflection of database growth. Especially full backups.
K. Brian Kelley
@kbriankelley
Viewing 15 posts - 1 through 14 (of 14 total)
You must be logged in to reply to this topic. Login to reply