Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
hardeepvirdee
Starting Member
2 Posts |
Posted - 2001-11-07 : 04:13:17
|
Sorry, just realised I posted this to the wrong board. Its meant to posted in the discussion about naming conventions - this is my first post. Hopefully one of the moderators will move it.----------------------------------------Just a word of caution regarding naming stored procedures, I'm sure many of you may already know this - though I've seen it done in msdn magazine a few times.Using 'sp_' as a prefix is not a good idea, because SQL Server will ALWAYS check the master database first for the stored procedure, before checking the current database. This is why you can access all the system stored procedures from any database. Try it out - place one of your stored procedures in the master database and you will be able to call it from another, even without using 'exec master..sp_myStoredProc' syntax.This can have a impact on performance, though how much of an impact I don't know.When naming my stored procedures I use the following rules:1. two letter prefix to give the natural grouping e.g. 'ac' for accounts2. the verb describing the action i.e. Get, Check, Update, Delete and Insert3. the name of the actioned entity - this should match the table name is some way4. and if applicable what parameters are used proceded with 'by'for example:acGetPaymentsbyUserIDacGetPaymentsbyDateRangeacGetPaymentsbyDateRangeAndUserIDacUpdatePaymentByUserIDacInsertPaymentusInsertUserusDeleteUserbyUserIDI find this leads to an easy way to know what your stored procedure does and allows natural grouping of them when in lists like the data view in visual interdev. Of course you have to be flexiable and I have used underscores and deviated from this when it helps.Edited by - hardeepvirdee on 11/07/2001 04:28:52 |
|
|
|
|