I’ve seen a query that looks like this:
Select Id from ..TableName where [Name] = @MyName
I can’t seem to find when, or why this would be used. The query session is run against a database (So there is a USE already), and then ‘TableName’ is in both the default schema (dbo) as well as an audit schema (audit.TableName).
What would the .. mean in this case, and is it required / useful?
Advertisement
Answer
SQL Server has a four-part naming convention for table references:
<server name>.<database name>.<schema name>.<table name>
Often the server is left off.
The ..
occurs when you are happy to use the default schema in the database you are referencing. The default is usually dbo
, but of course you can change it to something else. So, generally, it means:
from <current database>.dbo.TableName