Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Is there a recommended (official or not) style from Microsoft regarding naming and casing in T-SQL?

If there isn't one from Microsoft then is there one with broad acceptance?

share|improve this question
    
Can you be more specific? Are you referring to object names, database names, user names, column names? –  JNK Oct 17 '12 at 12:53
4  
Joe Celko wrote a whole book entitled "SQL Programming Style". It covers the subject in depth. –  AlexKuznetsov Oct 17 '12 at 13:11
    
Pretty much everything. There's one convention for C# for instance, then there must be one for T-SQL. –  gsb Oct 17 '12 at 13:11
add comment

2 Answers

> If there isn't one from Microsoft then is there one with broad acceptance?

There is no accepted coding standard for T-SQL. However, I've always found that the code authored by Itzik Ben-Gan in his books is a really good example of how naming, capitalisation, spacing, and layout can make T-SQL appear more readable and understandable (and even elegant).

If you want to follow any 'standard' I'd suggest looking here first.

share|improve this answer
add comment

There's no broad standard that I've seen used or heard widely recommended. Some recommend prefixing tables with tbl but some are very against that. Some, like myself, prefer to name the ID column simply so you always know what the ID column of any table will be called ID while others, like my coworker, prefer to put the tablename (ie - serverid) so what it's called in another table matches the column name in the parent table.

The most important thing is that the scheme you use remains consistent, especially within the same database. Most DBAs can pick up on the naming format as long as it doesn't change within an environment.

share|improve this answer
    
+1 for consistency –  dezso Oct 18 '12 at 8:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.