Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CODING STANDARDS

Status
Not open for further replies.

k108

Programmer
Joined
Jul 20, 2005
Messages
230
Location
US
With Oracle, all keywords are in UPPERCASE, as I recall.

Even variable names, like INT, etc... If my memory serves me correctly.

What do SQL Server programmers follow? Are there any commonly accepted standards? Also, specifically should it be INT or Int? Or DATETIME or DateTime?

Uppercase, lowercase, mixed case all over the place drives me batty :-)

Thanks
 
I think it is just a matter of perference. But usually an keywords or function names are all caps.
 
No standards but your own....

"A long life is when each day is full and every hour wide!"
(A Jewish Mentor)
M. [hourglass]

 
Check out Donutman's FAQs:

FAQ183-5275
FAQ183-5276
FAQ183-5277

-SQLBill

Posting advice: FAQ481-4875
 
I have seen a suggestion concerning naming of primary and foreign keys.

Primary Key should have ID in it: EmpID, CustomerID, etc.
Then a Foreign Key would be: EmpFK, CustomerFK, etc.

-SQLBill

Posting advice: FAQ481-4875
 
I generally try to avoid using abbreviations. This is especially true of object names such as tables, views, stored procedure, functions, and variables declared within them.

There are other places where abbreviations sneak in. For example, the following queryies are functionally identical.

Code:
Select DateDiff([red]d[/red], GetDate()-2, GetDate())
Select DateDiff([red]dd[/red], GetDate()-2, GetDate())
Select DateDiff([green]day[/green], GetDate()-2, GetDate())

I much prefer the last one.



-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Escpecially after realizing that "mm" doesn't do minutes. :P

Personally I don't like writing poetry (too long names), all caps (code looks like someone is YELLING to me) and "tbl" for table prefixes (yeah, user tables can mutate into potatoes any second). Everything else is negotiable - as long as coding standard is applied consistently.

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
I like using prefixes for tables that distinguish their purpose, e.g dtbl_ or dtable_ to denote a data table, ltbl_ or ltable_ to denote a look up table, stbl_ or stable_ to show that it's a system table.

I hated this at first, but was forced to use it b/c of a client's requirements, but have learned to love it.

Also, I tend to use just plain 'ole ID for my PK and EmployeeID (or whatever) to signify an FK as it tells me what table it's from.

Makes the crossover from db to vb coding much easier.

But again, as mentioned, personal preferences. Biggest thing is being consistent. Also, talk to other developers you may be working with directly so you're all on the same page.

Dale
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top