SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Database Growth History


Database Growth History

Author
Message
don.schaeffer
don.schaeffer
SSC-Enthusiastic
SSC-Enthusiastic (151 reputation)SSC-Enthusiastic (151 reputation)SSC-Enthusiastic (151 reputation)SSC-Enthusiastic (151 reputation)SSC-Enthusiastic (151 reputation)SSC-Enthusiastic (151 reputation)SSC-Enthusiastic (151 reputation)SSC-Enthusiastic (151 reputation)

Group: General Forum Members
Points: 151 Visits: 1062
I had a syntax error also; a database name on my system is a reserved word. Fix the issue by surrounding the database name in the dynamic sql with square brackets.

EXEC ('
INSERT INTO ##tbl_DataSize
SELECT CAST((SUM(size)) as DECIMAL(20,3)) FROM ['+@vcDatabaseName+'].dbo.sysfiles'
)
Snorri Kris
Snorri Kris
Grasshopper
Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)

Group: General Forum Members
Points: 15 Visits: 111
Thank you - problem solved.
(Needed also brackets for DB name: '.....FROM ['+@vcDatabaseName+'].dbo.sysfiles')
Mike Bourgeois
Mike Bourgeois
SSChasing Mays
SSChasing Mays (630 reputation)SSChasing Mays (630 reputation)SSChasing Mays (630 reputation)SSChasing Mays (630 reputation)SSChasing Mays (630 reputation)SSChasing Mays (630 reputation)SSChasing Mays (630 reputation)SSChasing Mays (630 reputation)

Group: General Forum Members
Points: 630 Visits: 958
Very nice script. Thanks.
Greg Milner
Greg Milner
SSC Veteran
SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)

Group: General Forum Members
Points: 221 Visits: 491
Very nice script.

I noticed that some of those ungodly long-named SharePoint databases were getting their names chopped off so I changed the variable and the #temp table column names to VARCHAR(128)

CREATE TABLE #tbl_GrowthData
(
DatabaseName VARCHAR(128)
...
...


DECLARE
...
,@vcDatabaseName VARCHAR(128)



G. Milner
Arju
Arju
Grasshopper
Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)

Group: General Forum Members
Points: 21 Visits: 54
Hi,

Absolutely this is a nice script.

i have a small doubt in this. Please assist.

.. Is it possible to see the file wise growth of the each DB ?.

So that we can confidently say that So and so file in the particular disk has grown this much %.

Thanks,
Arjun
Leon . Orlov .
Leon . Orlov .
SSC Journeyman
SSC Journeyman (80 reputation)SSC Journeyman (80 reputation)SSC Journeyman (80 reputation)SSC Journeyman (80 reputation)SSC Journeyman (80 reputation)SSC Journeyman (80 reputation)SSC Journeyman (80 reputation)SSC Journeyman (80 reputation)

Group: General Forum Members
Points: 80 Visits: 261
Thanks for sharing. Cool script.

You also might want to limit the data collection for only 'ONLINE' databases.

SELECT [name] FROM master.dbo.sysdatabases
WHERE DATABASEPROPERTYEX(name, 'status') = 'ONLINE'
ORDER BY [name]
OPEN file_cursor

~Leon
rw_ebox
rw_ebox
SSC Journeyman
SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)

Group: General Forum Members
Points: 83 Visits: 416
A nice script.

2 cents

If you run this script against SharepPoint database, please increase the following two variables.

1. DatabaseName VARCHAR(250)
2. ,@vcDatabaseName VARCHAR(250)

Thanks



Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search