Database Reference
In-Depth Information
Now let's look at the naming standard we are using in the model for
this topic. Again, this standard is not the only way, and your standard may
be very different, but we want you to understand our thinking before we
get into building the physical model. If, however, you like the standard laid
out here, we highly recommend its use because we have had great success
with it.
General Naming Guidelines
Whether you are naming tables, stored procedures, columns, or any other
SQL Server object, there are a few rules that you should plan to follow.
These rules ensure that the names you use will not cause problems and will
prevent you from having to add extra code when referencing these obj-
ects. We look at the general rules now and get into the object-specific rules
a little later. Again, these are not hard-and-fast rules, but they are good
guidelines.
Never Use Spaces in Object Names
Although SQL Server will happily allow you to enter names that contain
spaces, don't do it. A view name like “Orders by Customer” may seem like
a good idea (after all, it is descriptive), but you should avoid it at all costs.
Some applications are completely unable to deal with the space in an ob-
ject name, and your T-SQL code can deal with this name only if you en-
close it in square brackets, such as [Orders by Customer].
Never Use Hyphens in Object Names
Using hyphens (-), also commonly known as dashes, can cause a problem
similar to the one caused by using spaces. A hyphen in T-SQL is, among
other things, the minus operator. Using a hyphen in an object name not
only will confuse the compiler but also can lead to unexpected results.
Although a hyphen won't cause as many problems as a space, it is still wise
to avoid its use.
Do Not Name Objects Using SQL Server Keywords
This one can be a real pain. Naming an object with a keyword can lead to
all kinds of problems. The list of SQL Server keywords is too long to in-
clude here, but you will know it's a keyword if it turns blue in the SQL
Search WWH ::




Custom Search