Groups | Blog | Home
all groups > sql server msde > march 2006 >

sql server msde : Does anyone know a utility/batch script to Warn when close to Max DB size


Uffe Bak
3/28/2006 8:12:25 PM
Hello Group

Does anyone know of a utility or Batch script (osql or Windows cmd or mix)
to Warn an Admin when a MSDE DB is closing in on 2 GB in size (or 2005
Express closes in on 4 GB).

Any leads or tips will be appriciated highly

Best regards

Uffe

Satya SKJ
3/29/2006 5:57:05 AM
You could set up the performance condition alerts. Try the SQL
Server:Databases object. The counters would be Data File(s) Size (KB) and Log
File(s) Size (KB). Have it alert if the counters are above a certain
threshold. For instance, if your data file was 1024MB, then setup the alert
so that if the data file grows over 900MB in size, then alert. I don't think
that you can do a percentage here, so you will have to type in the size of
the files.

--
-----------------
Satya SKJ
Visit http://www.sql-server-performance.com for tips and articles on
Performance topic.


[quoted text, click to view]
Andrea Montanari
3/29/2006 3:56:33 PM
hi Uffe,
[quoted text, click to view]

in MSDE you can perhaps schedule a job defined to include a way to gather
that kind of data, using direct access to the sysfiles database table or via
DBCC SHOWFILESTATS..
you can then validate that data against a userdefined treshold and notify
someone via NET SEND or mail via SMPT alternative, like exploded in
http://www.karaszi.com/sqlserver/info_no_mapi.asp,
http://www.dbmaint.com/SmtpAlerter.asp , thus defining a kind of alert..
PRINT 'MSDE';
PRINT '-----------------';
USE Northwind;
PRINT 'sp_spaceused';
EXEC sp_spaceused @updateusage = 'TRUE';

PRINT '----';
PRINT 'DBCC SHOWFILESTATS';

CREATE TABLE #tmp_sfs (
fileid int,
filegroup int,
totalextents int,
usedextents int,
name varchar(1024),
filename varchar(1024)
);

INSERT INTO #tmp_sfs
EXECUTE('DBCC SHOWFILESTATS');


SELECT LEFT(DB_NAME(),10), (SUM(totalextents) * 64) / 1024 AS [totalextents
in MB], (SUM(usedextents) * 64) /1024 AS [usedextents in MB]
FROM #tmp_sfs;

DROP TABLE #tmp_sfs;

PRINT '----';
PRINT 'sysdatabase query';

SELECT LEFT(DB_NAME(),10) AS [Database], sum(convert(float,size)) * (8192.0
/1024.0) /1024.0 AS [Size in MB for Data files]
FROM dbo.sysfiles
WHERE (status & 0x40) <> 0x40;

SQLExpress does not provide the SQL Server Agent, so you can perhaps rely on
the native OS scheduler for something similar.. as regards the SMPT
integration, you have to (possibly) write your own CLR based mailer
solution.. I personally will... then, from the OS scheduler, you'll execute
SqlCmd command line tool to perform the SQLExpress connection and data
retrival...
just an idea..
--
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtm http://italy.mvps.org
DbaMgr2k ver 0.18.0 - DbaMgr ver 0.62.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
--------- remove DMO to reply

Uffe Bak
3/29/2006 8:47:42 PM
Thanks to Andrea and Satya for quick answers

I will look into your suggestions and return if I find a solution.
I also looked up some Scripting options, so there are as usual more than one
road to Rome

Best regards

Uffe Bak

Michelle
6/21/2006 10:30:02 AM
If you have a lot of databases whose expected growth rate cannot be easily
estimated, this can be hard to maintain. If you find that you regularly have
to change the max size b/c you had a bad estimate, you then have to update
the alert, too :) I don't know why they don't provide a % at the database
level for this in the alerts. We gather all of this data from system tables
like Andrea suggests and consolidate it into a single system. Then we use
reporting services to give us a report every morning that tells us (among
other things) if we have any databases that can only grow two more times.

[quoted text, click to view]
AddThis Social Bookmark Button