January 18, 2008 at 10:36 am
This may seem like a stupid question and I am pretty sure I already know the answer but I wanted to do a gut check and was unable to find the answer anywhere else.
Is it OK to create custom stored procedures in the MSDB system database?
I would think it would be fine but I really don't want to break anything and then have to explain to my boss what I broke and how I broke it.
I need to create a stored procedure to run a server side trace. I can't fit all the script into a job, and I really don't want to put it in any other databases, not create a db only to house a sp or two.
January 22, 2008 at 5:04 am
The MSDB database is one of the heaviest-used system databases. It stores everything from DTS packages to Jobs (and the history of each).
You can create but it will slow down the performance.
January 22, 2008 at 8:19 am
If there's a reason to store something in the system DB's - I'd put it in master (it's a reasonably common practice). Is there a specific reason you want to put it in MSDB? Like Vyas pointed out - MSDB is one of the files where all sorts of processing occurs, and I wouldn't modify it at all unless there's a darn good reason to do so.
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
January 22, 2008 at 8:25 am
Why Msdb ?!
Master is not confortable for you?
If you won't create any kind of Database support, but you want to use a SP, then this sp can be stored on the master sp site, isn't it ?
January 22, 2008 at 8:59 am
Why put it in either one? It will cause you issues during recovery (DR) if you need it. I've often seen people forget that these procedures are there, they recover the user database s and they're stuck. Or you might not want to restore master (or msdb).
Any reason not to make your own small administrative database and stick it in there?
January 22, 2008 at 10:20 am
sometimes it is valid to put custom SPs in master or msdb.
suppose you want an sp to be globally accessible? put it in master, prefix it sp_ all set. yes u need to take this into account in DR scenario, but this is not a big deal. SPs to do Backups, Greps, or send SMTP mail are good candidates for the master database. Also, can mark the object as system as well.
How about an SP to return job execution status and history? There is nothing wrong with putting that in msdb.
i do agree that i will avoid restoring master if possible -- often rather just restore user DBs and msdb to a new instance, so keeping the scripts available is important. and yes, having your own administrative db should be a must for DBAs
Putting user objects of any type in system databases should not be done without careful consideration, but there are certainly valid scenarios in which doing so is a good idea.
NOW -- the script for the trace the OP is asking for...if it's too big for a job, my recommendation is to put it in a file and execute with SQLCMD.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply