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
Old Hand
Old Hand (371 reputation)Old Hand (371 reputation)Old Hand (371 reputation)Old Hand (371 reputation)Old Hand (371 reputation)Old Hand (371 reputation)Old Hand (371 reputation)Old Hand (371 reputation)

Group: General Forum Members
Points: 371 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
SSC Rookie
SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)

Group: General Forum Members
Points: 45 Visits: 111
Thank you - problem solved.
(Needed also brackets for DB name: '.....FROM ['+@vcDatabaseName+'].dbo.sysfiles')
Mike Bourgeois
Mike Bourgeois
Say Hey Kid
Say Hey Kid (672 reputation)Say Hey Kid (672 reputation)Say Hey Kid (672 reputation)Say Hey Kid (672 reputation)Say Hey Kid (672 reputation)Say Hey Kid (672 reputation)Say Hey Kid (672 reputation)Say Hey Kid (672 reputation)

Group: General Forum Members
Points: 672 Visits: 958
Very nice script. Thanks.
Greg Milner
Greg Milner
SSChasing Mays
SSChasing Mays (637 reputation)SSChasing Mays (637 reputation)SSChasing Mays (637 reputation)SSChasing Mays (637 reputation)SSChasing Mays (637 reputation)SSChasing Mays (637 reputation)SSChasing Mays (637 reputation)SSChasing Mays (637 reputation)

Group: General Forum Members
Points: 637 Visits: 494
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
SSC Journeyman
SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)SSC Journeyman (87 reputation)

Group: General Forum Members
Points: 87 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 .
Old Hand
Old Hand (304 reputation)Old Hand (304 reputation)Old Hand (304 reputation)Old Hand (304 reputation)Old Hand (304 reputation)Old Hand (304 reputation)Old Hand (304 reputation)Old Hand (304 reputation)

Group: General Forum Members
Points: 304 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-Enthusiastic
SSC-Enthusiastic (161 reputation)SSC-Enthusiastic (161 reputation)SSC-Enthusiastic (161 reputation)SSC-Enthusiastic (161 reputation)SSC-Enthusiastic (161 reputation)SSC-Enthusiastic (161 reputation)SSC-Enthusiastic (161 reputation)SSC-Enthusiastic (161 reputation)

Group: General Forum Members
Points: 161 Visits: 428
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