SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Worst Practice - Spaces in Object Names


Worst Practice - Spaces in Object Names

Author
Message
Andy Warren
Andy Warren
SSC-Forever
SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)

Group: Moderators
Points: 44754 Visits: 2783
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/awarren/worstpracticespacesinobjectnames.asp>http://www.sqlservercentral.com/columnists/awarren/worstpracticespacesinobjectnames.asp

Andy
SQLAndy - My Blog!
Connect with me on LinkedIn
Follow me on Twitter
scaleovenstove
scaleovenstove
Valued Member
Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)Valued Member (56 reputation)

Group: General Forum Members
Points: 56 Visits: 67
also, not only table naming conventions, but field naming conventions. it is really tough to write queries that join two tables where they both have fields named "id" to join on. It gets even worse when you add more fields, joins, etc. True, you can alias columns and tables (a.id = b.id), but that is a pain and is avoidable by naming the fields the "right" way!



philcart
philcart
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18423 Visits: 1441
add to this, avoiding the use of non-alphanumeric characters, wildcards, etc...
eg: tblName%

Arrrgghh!!!!

Hope this helps
Phill Carter
--------------------
Colt 45 - the original point and click interface

Hope this helps
Phill Carter
--------------------
Colt 45 - the original point and click interface

Australian SQL Server User Groups - My profile
Phills Philosophies
Murrumbeena Cricket Club
Dave Poole
Dave Poole
One Orange Chip
One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)One Orange Chip (29K reputation)

Group: General Forum Members
Points: 29896 Visits: 3604
I agree with this 100%
  • Don't use spaces in table names
  • Stick to alphanumerics, (preferably without the numerics unless you absolutely must)
  • Don't use reserved words for tables i.e have a table called "Order" or "Exists"!


I think a "best practices" option should be added to YUKON so default naming conventions can be enforced. For example, pattern match object names.

LinkedIn Profile
www.simple-talk.com
steveshellard
steveshellard
Valued Member
Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)Valued Member (51 reputation)

Group: General Forum Members
Points: 51 Visits: 2
I guess people do it for readability, but I've always used the '_' (underscore) if I've needed to put a gap between words in a table name.

eg. New_Table_Name



Jonr
Jonr
SSC Eights!
SSC Eights! (976 reputation)SSC Eights! (976 reputation)SSC Eights! (976 reputation)SSC Eights! (976 reputation)SSC Eights! (976 reputation)SSC Eights! (976 reputation)SSC Eights! (976 reputation)SSC Eights! (976 reputation)

Group: General Forum Members
Points: 976 Visits: 65
Totally agree - bad enough that data types can't be standardised across databases/programming languages, let alone adding nonsense like spaces and underscores to object names. Added to which, doesn't it contravene ANSI standard SQL, which would make it more difficult to port?

Jon Reade

Edited by - jonreade on 10/01/2003 03:52:31 AM


Jon
Andy Warren
Andy Warren
SSC-Forever
SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)

Group: Moderators
Points: 44754 Visits: 2783
I'm going to a follow up to hit on the object naming thing a little harder - you guys are right, spaces arent the only bad thing. Just particularly objectionalble to me!

Andy
http://www.sqlservercentral.com/columnists/awarren/

Andy
SQLAndy - My Blog!
Connect with me on LinkedIn
Follow me on Twitter
Lara Rubbelke
Lara Rubbelke
Mr or Mrs. 500
Mr or Mrs. 500 (514 reputation)Mr or Mrs. 500 (514 reputation)Mr or Mrs. 500 (514 reputation)Mr or Mrs. 500 (514 reputation)Mr or Mrs. 500 (514 reputation)Mr or Mrs. 500 (514 reputation)Mr or Mrs. 500 (514 reputation)Mr or Mrs. 500 (514 reputation)

Group: General Forum Members
Points: 514 Visits: 67
Thank you! I have been fighting this battle for years! Nothing is as frustrating as writing out the query, or grabbing columns from the object browser, hitting execute and getting an error because I need brackets around some object. Egad! Just don't do it! Embrace the non-spaced object naming convention!

There are indeed many "worst practices" to avoid, but this is so easy to avoid.



Robert W Marda
Robert W Marda
SSCertifiable
SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)SSCertifiable (5.5K reputation)

Group: General Forum Members
Points: 5525 Visits: 140
I see no reason to use spaces for object names or column names. To me TableName is just as easy to read as Table Name and then I don't have to see those brackets which just cluter up the screen.

Robert W. Marda
SQL Programmer
bigdough.com
The world’s leading capital markets contact database and software platform.

Robert W. Marda
Billing and OSS Specialist - SQL Programmer
MCL Systems
John Langston
John Langston
Right there with Babe
Right there with Babe (746 reputation)Right there with Babe (746 reputation)Right there with Babe (746 reputation)Right there with Babe (746 reputation)Right there with Babe (746 reputation)Right there with Babe (746 reputation)Right there with Babe (746 reputation)Right there with Babe (746 reputation)

Group: General Forum Members
Points: 746 Visits: 526
I blame the practice on Access database users. Access allows this practice and then if the Access database has to be moved to SQL Server, those tasked with the move get bitten.



Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum







































































































































































SQLServerCentral


Search