Ask SQLTeam Question
Posted - 06/12/2001 : 22:27:41
| Prabhakanth writes "I am using SQLServer 2000.
I created a new database and ported data into it.At this stage the size of the database was 35MB. The initial growth percent was set at default(10%). There was no max size specified. Then the database went live and after two weeks the database size grew to 941MB. This is pretty strange as initial data that was ported was data for two months, and approximating the datasize/day entry to be around 2.5MB it would mean a max. size of around 70MB at the end of two weeks. The questions that i have in mind are:
Q1) Could you tell me as to why it has grown to 941MB?
Q2)The possible solutions for the above ?
Q3)Is it advisable to shrink it by a large percentage and see what happens?
Q4)Possible measures to keep the file growth in check,assuming a 2-4MB/DAY data entry.
PS: Pls reply at the earliest."
Posted - 06/13/2001 : 08:47:13
| I keep meaning to post this somewhere - it's something that the live servers email to me every day so that I have a recored of how databases and tables are growing - runs on v7 but shouldn't be difficult to get working on v2000. Note the first one has the xp_sendmail in the sp - the second is better as the xp_sendmail is in the job but haven't changed the first yet.
create procedure spReportDiscSpace
create table ##DiscSpace (s varchar(100), id int identity (1,1))
exec master..xp_cmdshell 'dir d:\mssql7\data'
exec master..xp_cmdshell 'dir d:\mssql7\backups\'
declare @s varchar(100) ,
select @freespace = (
select top 1 ltrim(rtrim(s))
where s like '%bytes free%'
select @s = rtrim(srvname) + ' disk space report at ' + convert(varchar(20),getdate(),113) + ' ' + @freespace
where srvid = 0
@recipients = 'email@example.com' ,
@width = 2000 ,
@subject = @s ,
@query = 'select s from ##DiscSpace order by id'
drop table ##DiscSpace
create procedure spReportTableSpace
set nocount on
create table #Report (s varchar(1000), id int identity (1,1))
create table #a (name varchar(128), size int, id int identity)
select name ,
where type = 'U'
declare @name varchar(128)
create table #b (name varchar(128), rows varchar(128), reserved varchar(128) , data varchar(128), index_size varchar(128), unused varchar(128))
declare @id int
select @id = 0
while @id < (select max(id) from #a)
select @id = min(id) from #a where id > @id
select @name = name from #a where id = @id
exec dbname..sp_spaceused @name
set size = convert(int,left(reserved,datalength(reserved) - 3))
where #a.id = @id
select 'total used space by tables = ' + convert(varchar(10),sum(size)) + ' kb'
insert #Report select ''
insert #report (s)
select right(space(15) + convert(varchar(10),size) + ' kb', 15) + ' ' + name from #a
order by size desc
drop table #a
drop table #b
order by id