DB Stored Procedures - where?

  • Good Morning,

    Should database stored procedures be stored in the "master" db or in a dba created db ie: "employee" db? What are the pro and cons to these startegies?

    Many thanks.

    Jeff

    Many thanks. Jeff

  • Hi,

    Storing procedures in the master database would not be my first choice unless the procedure is an administration procedure or you are creating an extended stored procedure.

    A more important issue is what you call the procedure. Try to avoid calling the procedure "sp_Procedure" (SPs in the master DB are prefixed SP_). If the procedure is in a database other than the master and has a name the same as a procedure in the master database, the master db is always checked first so there can be a conflict.

    It would be a good idea to keep all the stored procedures relating to that particular DB within that DB. It is also easier to manage if you need to script the entire database.

    Regards

    Graeme

  • Agree with Graeme.

    Keep all the DB sp's in one place. It makes it more managable. Also, you have to consider the implications of extra permissions to enable you to execute SP's accross databases. If all your objects are within the same database and all owned by dbo, for example, then you won't break any owenership chains...

    Clive Strong

    cstrong@kingston-technology.com

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply