views:

884

answers:

5

There are seemingly a lot of very diversive naming convention recommendations for sql server objects. I was wondering if there are some formal guidelines other than not prefixing stored procedures with sp_ ?


As pointed out by Matt, there is already a similar question: http://stackoverflow.com/questions/7662/database-table-and-column-naming-conventions , so please vote for closing this one (I don't understand why I can't close my own question?!?).

A: 

I normally just use a prefix using the first three letters of the table I'm working in for all items (i.e. empID).

Lucas McCoy
+1  A: 

i use usp for sprocs, udf for functions, vw for views and trig for triggers. i don't use anything for tables.

this isn't necessary and some don't reccomend it but this way i keep the grouping of the same objects if i'm querying sysobjects or similar.

Mladen Prajdic
A: 

Although it's probably not necessary, I prefix some object types:

tr_  for triggers
fn_  for user defined functions

There are not a lot of the above and the prefix makes them easier to find in the source.

For tables and stored procedures, and most views, I use a prefix that indicates the business area of the object. For example in my current project

dal_  for CRUD select, insert, delete
ac_  accounting functions
rep_ for reports
se_   security

...

and so on. Makes it easier to find a stored procedure or to know the purpose of a table.

MikeW
A: 

Well I used to use tblTableName, vwViewName, spStoredProcedure fldFieldName. Now after having worked with Databases for some time, I find the tbl, vw, and fld unnecessary extra characters to type.

I do stick with the spStoredProcedure though, not sure why but it's pretty easy to type spSomething.

For tables, I now name them with something descriptive and the same for fields. I generally use lowercase for the first word and then uppercase on the first letter of the second word.

ie: employeeRecords, spGetEmployees, etc.

Eppz
+1  A: 

never use this type of naming convention