Quantcast
Channel: Answers for "Using dot in naming databases in SQL"
Viewing all articles
Browse latest Browse all 4

Answer by Bob Hovious

$
0
0

Dots will definitely cause an issue, because they are used in qualifying names of objects. Compare the following:

sampleDB.dbo.sampleTable

sampleDB.net.dbo.sampleTable

The first example designates that sampleTable is found in the sampleDB. The second would be incorrectly interpreted as sampleTable in the net db on a linked server called sampleDB.

Dashes also have significance in SQL syntax. Try executing the statement "USE ABC-VER1" and see that it will fail.

To avoid these issues, any db references would have to ALWAYS represent the database name in brackets like this. Brackets would even allow you to have spaces in your database names.

[sampleDB.net].dbo.sampleTable

[sampleDB-ver1].dbo.sampleTable

[my database].dbo.sampleTable

If you are prepared to pay the price in minor hiccups when someone forgets to follow this convention, then go right ahead. I dislike the readability of brackets and prefer to use underscore as a name separator, if one is used at all.

sampledb_ver1.dbo.sampleTable

SampleDBVer1.dbo.sampleTable

All of these comments are made strictly in the context of MS-SQL Server. Connectivity with other vendor's products may be affected by the use of dots or dashes in names, but I can't speak to that from firsthand knowledge.


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images