Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Custom Stored Procedures in MSDB Expand / Collapse
Author
Message
Posted Friday, January 18, 2008 10:36 AM


Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Thursday, January 24, 2013 3:57 PM
Points: 51, Visits: 160
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.
Post #445019
Posted Tuesday, January 22, 2008 5:04 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Monday, September 30, 2013 2:09 AM
Points: 3,131, Visits: 1,058
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.



Post #445830
Posted Tuesday, January 22, 2008 8:19 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 6:44 PM
Points: 7,084, Visits: 14,684
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?
Post #445890
Posted Tuesday, January 22, 2008 8:25 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, May 13, 2010 9:24 AM
Points: 22, 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 ?
Post #445894
Posted Tuesday, January 22, 2008 8:59 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Yesterday @ 4:31 PM
Points: 32,780, Visits: 14,941
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
Post #445914
Posted Tuesday, January 22, 2008 10:20 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Friday, November 15, 2013 4:46 PM
Points: 69, 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.
Post #445983
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse