SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Custom Stored Procedures in MSDB


Custom Stored Procedures in MSDB

Author
Message
nick harris-294131
nick harris-294131
SSC Journeyman
SSC Journeyman (79 reputation)SSC Journeyman (79 reputation)SSC Journeyman (79 reputation)SSC Journeyman (79 reputation)SSC Journeyman (79 reputation)SSC Journeyman (79 reputation)SSC Journeyman (79 reputation)SSC Journeyman (79 reputation)

Group: General Forum Members
Points: 79 Visits: 182
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.
Chandra Sekhara Vyas Dhara
Chandra Sekhara Vyas Dhara
SSCarpal Tunnel
SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)

Group: General Forum Members
Points: 4205 Visits: 1149
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.



Matt Miller (4)
Matt Miller (4)
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12339 Visits: 18574
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?
RobertoRai
RobertoRai
SSC Rookie
SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)SSC Rookie (28 reputation)

Group: General Forum Members
Points: 28 Visits: 41
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 ?
Steve Jones
Steve Jones
SSC Guru
SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)

Group: Administrators
Points: 62985 Visits: 19111
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?

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
russell-154600
russell-154600
SSC-Enthusiastic
SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)

Group: General Forum Members
Points: 109 Visits: 185
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.
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