Showing posts with label conventions. Show all posts
Showing posts with label conventions. Show all posts

Tuesday, March 20, 2012

Conventions, Style, and Best Practices

I'm looking for a concise guide to SQL programming style -- covering things
like naming conventions and other best practices or de facto standards.
Yes - I found Celko's SQL Programming Style book and plan to get a copy; I'd
also appreciate recommendations for something a bit more consise.
Thanks!Celko's book is only a couple hundred pages but has a lot of good info.
Here's a nice concise summary of a naming convention for you:
* When possible use only letters A - Z, underscore character (_), numeric
digits 0 - 9 and unicode standard 3.2 "letters" for names
* Avoid using "@.@." as a prefix for local variable names
* Don't use T-SQL reserved words as identifiers; you might want to avoid
ODBC reserved words as well
* Limit the length of identifiers (I find about 30 characters or less works
nicely)
* Use underscore characters and/or mixed case to differentiate words in
identifiers; avoid all upper- or all lower-case for identifiers
* Don't use "sp_" as a prefix for stored procedures (also avoid "xp_", "dt_"
and "MS_" prefixes).
* Choose a style and be consistent (don't call your local variable
@.myLocalVariable in one place and @.MYlocalVARIABLE in another - makes it
difficult to read and might cause problems in a case-sensitive DB).
"Jeff" <A@.B.COM> wrote in message
news:eqwIPacjGHA.4512@.TK2MSFTNGP02.phx.gbl...
> I'm looking for a concise guide to SQL programming style -- covering
> things like naming conventions and other best practices or de facto
> standards. Yes - I found Celko's SQL Programming Style book and plan to
> get a copy; I'd also appreciate recommendations for something a bit more
> consise.
> Thanks!
>

conventions about namereferences

Hallo,
Can someone tell me the difference between pcd_mn..nslAfdeling and
pcd_mn.dbo.nslAfdeling?
I know that in this case pcd_mn references the database on the server
and nslAfdeling a table in that database. I also know that dbo
references the owner of the database, but who is '..'?
Thnx in advance for replying
Groeten RonWell, if you dont specify the owner ('..' syntax) then SQL server first
assumes that you are the owner of the object (googleRon.nslAfdeling). If
that object doesnt exists it goes with the default 'dbo' owner and finds the
table under 'dbo.nslAfdeling'. So, the behaviour should be the same, but I
would recommend using table owner.
MC
"googleRon" <ronvdheijden@.gmail.com> wrote in message
news:1148374201.120687.276900@.j55g2000cwa.googlegroups.com...
> Hallo,
> Can someone tell me the difference between pcd_mn..nslAfdeling and
> pcd_mn.dbo.nslAfdeling?
> I know that in this case pcd_mn references the database on the server
> and nslAfdeling a table in that database. I also know that dbo
> references the owner of the database, but who is '..'?
> Thnx in advance for replying
> Groeten Ron
>|||Marko,
Thnx.
Ron