Metadata Functions



Metadata Functions in SQL Server


Metadata functions in SQL returns information about the database and database objects.


All the functions are listed below along with their explanations:

FunctionDescription
@@PROCIDReturns the object identifier (ID) of the current Transact-SQL module. A Transact-SQL module can be a stored procedure, user-defined function, or trigger.
Syntax:

@@PROCID
FunctionDescription
COL_LENGTHReturns the defined length, in bytes, of a columns.
Syntax:

COL_LENGTH ( '<table_name>', '<column_name>' )
FunctionDescription
ASSEMBLYPROPERTYReturns information about a property of an assembly
Syntax:

ASSEMBLYPROPERTY ( '<assembly_name>', '<property_name>' )
FunctionDescription
COL_NAMEReturns the name of a column from a specified corresponding table identification number and column identification number.
Syntax:

COL_NAME ( <table_id>, <column_id> )
FunctionDescription
COLUMNPROPERTYReturns information about a column or procedure parameter.
Syntax:

COLUMNPROPERTY ( <id>, '<column_name>', '<property_name>' )
FunctionDescription
DATABASEPROPERTYReturns the named database property value for the specified database and property name.
Syntax:

DATABASEPROPERTY ( '<database_name>', '<property_name>' )
FunctionDescription
DATABASEPROPERTYEXReturns the current setting of the specified database option or property for the specified database.
Syntax:

DATABASEPROPERTYEX ( '<database_name>', '<property_name>' )
FunctionDescription
DB_IDReturns the database identification (ID) number.
Syntax:

DB_ID ( [ '<database_name>' ] )
FunctionDescription
DB_NAMEReturns the database name.
Syntax:

DB_ID ( [ <database_id> ] )
FunctionDescription
FILE_IDReturns the file identification (ID) number for the given logical file name in the current database
Syntax:

FILE_ID ( '<file_name>' )
FunctionDescription
FILE_IDEXReturns the file identification (ID) number for the specified logical file name of the data, log, or full-text file in the current database.
Syntax:

FILE_IDEX ( '<file_name>' )
FunctionDescription
FILE_NAMEReturns the logical file name for the given file identification (ID) number.
Syntax:

FILE_NAME ( <file_id> )
FunctionDescription
FILEGROUP_IDReturns the filegroup identification (ID) number for a specified filegroup name.
Syntax:

FILEGROUP_ID ( '<filegroup_name>' )
FunctionDescription
FILEGROUP_NAMEReturns the filegroup name for the specified filegroup identification (ID) number
Syntax:

FILEGROUP_NAME ( <filegroup_id> )

FunctionDescription
FILEGROUPPROPERTYReturns the specified filegroup property value when specified with a filegroup and property name.
Syntax:

FILEGROUPPROPERTY ( '<filegroup_name>', '<property_name>' )
FunctionDescription
FILEPROPERTYReturns the specified file name property value when a file name and property name are specified.
Syntax:

FILEPROPERTY ( '<file_name>', '<property_name>' )
FunctionDescription
fn_listextendedpropertyReturns extended property values of database objects.
Syntax:

fn_listextendedproperty ( { default | '<property_name>' | NULL },
                          { default | '<level0_object_type>' | NULL },
                          { default | '<level0_object_name>' | NULL },
                          { default | '<level1_object_type>' | NULL },
                          { default | '<level1_object_name>' | NULL },
                          { default | '<level2_object_type>' | NULL },
                          { default | '<level2_object_name>' | NULL } )
FunctionDescription
FULLTEXTCATALOGPROPERTYReturns information about full-text catalog properties.
Syntax:

FULLTEXTCATALOGPROPERTY ( '<catalog_name>, '<property_name>' )
FunctionDescription
FULLTEXTSERVICEPROPERTYReturns information related to the properties of the Full-Text Engine. These properties can be set and retrieved by using sp_fulltext_service.
Syntax:

FULLTEXTSERVICEPROPERTY ( '<property_name>' )
FunctionDescription
INDEX_COLReturns the indexed column name. Returns NULL for XML indexes.
Syntax:

INDEX_COL ( '[<database_name>. [<schema_name>] . | <schema_name> ] 
              <table_or_view_name>', <index_id>, <key_id> )
FunctionDescription
INDEXKEY_PROPERTYReturns information about the index key. Returns NULL for XML indexes.
Syntax:

INDEXKEY_PROPERTY ( <object_id>, <index_id>, <key_id>, '<property_name>' )
FunctionDescription
INDEXPROPERTYReturns the named index or statistics property value of a specified table identification number, index or statistics name, and property name. Returns NULL for XML indexes
Syntax:

INDEXPROPERTY ( <object_id>, '<index_or_statistics_name>',
               '<property_name>' )
FunctionDescription
OBJECT_IDReturns the database object identification number of a schema-scoped object.
Syntax:

OBJECT_ID ( '[<database_name>. [<schema_name>] . | <schema_name> ] 
             <object_name>', [ '<object_type>' ] )
FunctionDescription
OBJECT_NAMEReturns the database object name for schema-scoped objects.
Syntax:

OBJECT_NAME ( <object_id> [, <database_id> ] )
FunctionDescription
OBJECTPROPERTYReturns information about schema-scoped objects in the current database. This function cannot be used on objects that are not schema-scoped, such as data definition language (DDL) triggers and event notifications.
Syntax:

OBJECTPROPERTY ( <object_id>, '<property_name>' )
FunctionDescription
OBJECTPROPERTYEXReturns information about schema-scoped objects in the current database.
Syntax:

OBJECTPROPERTYEX ( <object_id>, '<property_name>' )
FunctionDescription
SCHEMA_IDReturns the schema ID associated with a schema name.
Syntax:

SCHEMA_ID ( [ '<schema_name>' ] )
FunctionDescription
SCHEMA_NAMEReturns the schema name associated with a schema ID.
Syntax:

SCHEMA_NAME ( [ <schema_id> ] )
FunctionDescription
SQL_VARIANT_PROPERTYReturns the base data type and other information about a sql_variant value.
Syntax:

SQL_VARIANT_PROPERTY ( '<expression>', '<property_name>' )
FunctionDescription
TYPE_IDReturns the ID for a specified data type name.
Syntax:

TYPE_ID ( '[<schema_name>.] <type_name>' )
FunctionDescription
TYPE_NAMEReturns the unqualified type name of a specified type ID.
Syntax:

TYPE_NAME ( <type_id> )
FunctionDescription
TYPEPROPERTYReturns information about a data type
Syntax:

TYPEPROPERTY ( '<type_name>', '<property_name>' )

Connection String

SQL Server Connection String Formats

posted on 2019-08-27 05:53:53 - SQL Server Tutorials


UNION

union in SQL server

posted on 2019-08-09 23:05:33 - SQL Server Tutorials


System Functions

System Functions in SQL Server

posted on 2019-08-09 06:14:33 - SQL Server Tutorials


Prompt Examples

ChatGPT Prompt Examples

posted on 2023-06-21 22:37:19 - ChatGPT Tutorials


Use Cases

Chat GPT Key Use Cases

posted on 2023-06-21 21:03:17 - ChatGPT Tutorials


Prompt Frameworks

Prompt Frameworks

posted on 2023-06-21 19:33:06 - ChatGPT Tutorials