February 15, 2014

SQL Server - Four Part Name

The name of a database object can be a four-part name in the following form:

server_name.[database_name].[schema_name].object_name - Four part name

server_name.[database_name]..object_name - Schema name is omitted.

server_name..[schema_name].object_name - Database name is omitted.

server_name...object_name - Database and schema name is omitted.


server name:It can be either remote server name or linked server name.

Example:
SELECT * FROM DatabaseName.Master.dbo.sysobjects

database_name: If the object is at local instance of SQL Server then it will be SQL Server database name, or if the object is at linked server then it will be OLE DB catalog.

Example:
SELECT * FROM Master.dbo.sysobjects

schema_name: It will be the name of the schema that contains the object if the object is in a SQL Server database, or if the object is in linked server then it will be OLE DB schema name.

Example:
SELECT * FROM dbo.sysobjects

object_name: It is the name of the object.

Example:
SELECT * FROM sysobjects

No comments: