Vadzim Savenok Vadzim Savenok - 3 months ago 6
SQL Question

What is the meaning of the dot in SQL from statement

Let's say we have a simple query

SELECT something
FROM name_before_dot.name_after_dot


What is the meaning of the dot in the FROM clause?

Is it some kind of separator or is it just a table name with the dot in it?

Mind you, I have already searched SO, its threads were talking about dot in select or where, which I know are related to aliases, dot in from is still a mystery to me.

Answer

This is a database schema. Full three-part name of a table is:

databasename.schemaname.tablename

For a default schema of the user, you can also omit the schema name:

databasename..tablename

You can also specify a linked server name:

servername.databasename.schemaname.tablename

You can read more about using identifiers as table names on MSDN:

The server, database, and owner names are known as the qualifiers of the object name. When you refer to an object, you do not have to specify the server, database, and owner. The qualifiers can be omitted by marking their positions with a period. The valid forms of object names include the following:

server_name.database_name.schema_name.object_name

server_name.database_name..object_name

server_name..schema_name.object_name

server_name...object_name

database_name.schema_name.object_name

database_name..object_name

schema_name.object_name

object_name

An object name that specifies all four parts is known as a fully qualified name. Each object that is created in Microsoft SQL Server must have a unique, fully qualified name. For example, there can be two tables named xyz in the same database if they have different owners.

Most object references use three-part names. The default server_name is the local server. The default database_name is the current database of the connection. The default schema_name is the default schema of the user submitting the statement. Unless otherwise configured, the default schema of new users is the dbo schema.