Inevitably, the need arises to create scripts and stored procedures to administer a SQL Server. The options as to where to house these utilities range from stuffing them into the master database to keeping them on the administrator's client computer in a mesh of flat files. While I would agree that any method will work if you establish a good procedure, I would additionally argue that most procedures are inherently self limiting. Try recovering stored procedures compiled into the master database after you've been forced to rebuild master or applying a routine data fix process when the computer where the script is stored is having its mail client upgraded and you'll get an introduction to the reality of such limits. If you create a user database to store all the admin stored procedures, scripts and utility tables, the procedures remain available to any SQL client and can be easily recreated from a dump if disaster strikes the SQL Server.
Integration of a user database to the SQL Enterprise Manager's Scheduler, the command line, and the network constitutes a subsystem intended for SQL Server administration. What follows is a working example of such a subsystem.
This subsystem could actually be set up on a SQL Server Workstation as a stand alone administrator SQL Server. Using a combination of remote stored procedure calls (only used here to check the status of dumps and loads in msdb) and isql to keep processing local to the server where the operations are executing, the admin subsystem does not need to live where it works.
DATABASE: 10MB with log on data device, truncate on checkpoint enabled, and no users except dbo (mapped to the sa login)
USE master
GO
----------------- Device ---------------
DISK INIT
NAME = "admin_dev",
PYHSNAME = "E:\admin_dev.DAT",
VDEVNO = 99,
SIZE = 5120
----------------- Space and Log ---------------
CREATE Database admin
on admin_dev = 10 -- 5120 of two Kb pages
--------------------- DB Options -------------------
EXECute sp_dboption admin ,'ANSI null default' , false
EXECute sp_dboption admin ,'dbo use only', false
EXECute sp_dboption admin ,'no chkpt on recovery', TRUE
/***EXECute sp_dboption admin ,'offline', false***/
/***EXECute sp_dboption admin ,'published', false***/
EXECute sp_dboption admin ,'read only', false
EXECute sp_dboption admin ,'select into/bulkcopy, false
EXECute sp_dboption admin ,'single user', false
/***EXECute sp_dboption admin ,'subscribed', false***/
EXECute sp_dboption admin ,'trunc. log on chkpt.', false
-------------------- sa is dbo ---------------------
TABLES:
SCRIPTS (Add to table admin..scripts):
If you read this far, you might be planning on trying the subsystem. You can now download the admin database schema and a character mode bcp output file of the scripts table content.