3

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: 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?!?).

Community
  • 1
  • 1
Manu
  • 28,753
  • 28
  • 75
  • 83
  • Duplicate of http://stackoverflow.com/questions/7662/database-table-and-column-naming-conventions ? – Matt Hamilton Feb 24 '09 at 23:00
  • 1
    Does this answer your question? [Database, Table and Column Naming Conventions?](https://stackoverflow.com/questions/7662/database-table-and-column-naming-conventions) – DavidRR Apr 07 '22 at 13:57

4 Answers4

2

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
  • 15,457
  • 2
  • 43
  • 51
0

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

Kredns
  • 36,461
  • 52
  • 152
  • 203
0

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
  • 5,702
  • 1
  • 35
  • 43
0

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
  • 3,178
  • 2
  • 19
  • 26