Skip to content

Commit 69b5efb

Browse files
committed
Refresh sys.columns and fix incorrect name (UUF 265898)
1 parent 6989209 commit 69b5efb

File tree

1 file changed

+64
-70
lines changed

1 file changed

+64
-70
lines changed

docs/relational-databases/system-catalog-views/sys-columns-transact-sql.md

Lines changed: 64 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "sys.columns (Transact-SQL)"
33
description: sys.columns (Transact-SQL)
44
author: rwestMSFT
55
ms.author: randolphwest
6-
ms.date: "05/24/2022"
6+
ms.date: 06/20/2024
77
ms.service: sql
88
ms.subservice: system-objects
99
ms.topic: "reference"
@@ -14,81 +14,75 @@ helpviewer_keywords:
1414
- "sys.columns catalog view"
1515
dev_langs:
1616
- "TSQL"
17-
monikerRange: ">=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current||=fabric"
17+
monikerRange: ">=aps-pdw-2016 || =azuresqldb-current || =azure-sqldw-latest || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric"
1818
---
1919

2020
# sys.columns (Transact-SQL)
2121

2222
[!INCLUDE [sql-asdb-asdbmi-asa-pdw-fabricse-fabricdw](../../includes/applies-to-version/sql-asdb-asdbmi-asa-pdw-fabricse-fabricdw.md)]
2323

24-
Returns a row for each column of an object that has columns, such as views or tables. The following is a list of object types that have columns:
25-
26-
- Table-valued assembly functions (FT)
27-
28-
- Inline table-valued SQL functions (IF)
29-
30-
- Internal tables (IT)
31-
32-
- System tables (S)
33-
34-
- Table-valued SQL functions (TF)
35-
36-
- User tables (U)
37-
38-
- Views (V)
39-
40-
|Column name|Data type|Description|
41-
|-----------------|---------------|-----------------|
42-
|object_id|**int**|ID of the object to which this column belongs.|
43-
|name|**sysname**|Name of the column. Is unique within the object.|
44-
|column_id|**int**|ID of the column. Is unique within the object.<br /><br /> Column IDs might not be sequential.|
45-
|system_type_id|**tinyint**|ID of the system type of the column.|
46-
|user_type_id|**int**|ID of the type of the column as defined by the user.<br /><br /> To return the name of the type, join to the [sys.types](../../relational-databases/system-catalog-views/sys-types-transact-sql.md) catalog view on this column.|
47-
|max_length|**smallint**|Maximum length (in bytes) of the column.<br /><br /> -1 = Column data type is **varchar(max)**, **nvarchar(max)**, **varbinary(max)**, or **xml**.<br /><br /> For **text**, **ntext**, and **image** columns, the max_length value will be 16 (representing the 16-byte pointer only) or the value set by sp_tableoption 'text in row'.|
48-
|precision|**tinyint**|Precision of the column if numeric-based; otherwise, 0.|
49-
|scale|**tinyint**|Scale of column if numeric-based; otherwise, 0.|
50-
|collation_name|**sysname**|Name of the collation of the column if character-based; otherwise `NULL`.|
51-
|is_nullable|**bit**|1 = Column is nullable.|
52-
|is_ansi_padded|**bit**|1 = Column uses ANSI_PADDING ON behavior if character, binary, or variant.<br /><br /> 0 = Column is not character, binary, or variant.|
53-
|is_rowguidcol|**bit**|1 = Column is a declared ROWGUIDCOL.|
54-
|is_identity|**bit**|1 = Column has identity values|
55-
|is_computed|**bit**|1 = Column is a computed column.|
56-
|is_filestream|**bit**|1 = Column is a FILESTREAM column.|
57-
|is_replicated|**bit**|1 = Column is replicated.|
58-
|is_non_sql_subscribed|**bit**|1 = Column has a non-SQL Server subscriber.|
59-
|is_merge_published|**bit**|1 = Column is merge-published.|
60-
|is_dts_replicated|**bit**|1 = Column is replicated by using [!INCLUDE[ssIS](../../includes/ssis-md.md)].|
61-
|is_xml_document|**bit**|1 = Content is a complete XML document.<br /><br /> 0 = Content is a document fragment or the column data type is not **xml**.|
62-
|xml_collection_id|**int**|Nonzero if the data type of the column is **xml** and the XML is typed. The value will be the ID of the collection containing the validating XML schema namespace of the column.<br /><br /> 0 = No XML schema collection.|
63-
|default_object_id|**int**|ID of the default object, regardless of whether it is a stand-alone object [sys.sp_bindefault](../../relational-databases/system-stored-procedures/sp-bindefault-transact-sql.md), or an inline, column-level DEFAULT constraint. The parent_object_id column of an inline column-level default object is a reference back to the table itself.<br /><br /> 0 = No default.|
64-
|rule_object_id|**int**|ID of the stand-alone rule bound to the column by using sys.sp_bindrule.<br /><br /> 0 = No stand-alone rule. For column-level CHECK constraints, see [sys.check_constraints &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/sys-check-constraints-transact-sql.md).|
65-
|is_sparse|**bit**|1 = Column is a sparse column. For more information, see [Use Sparse Columns](../../relational-databases/tables/use-sparse-columns.md).|
66-
|is_column_set|**bit**|1 = Column is a column set. For more information, see [Use Sparse Columns](../../relational-databases/tables/use-sparse-columns.md).|
67-
|generated_always_type|**tinyint**|**Applies to**: [!INCLUDE[sssql16-md](../../includes/sssql16-md.md)] and later, [!INCLUDE[ssSDS_md](../../includes/sssds-md.md)]. 5, 6, 7, 8 only applies to [!INCLUDE[ssSDS_md](../../includes/sssds-md.md)].<br /><br /> Identifies when the column value is generated (will always be 0 for columns in system tables):<br /><br /> 0 = NOT_APPLICABLE<br /> 1 = AS_ROW_START<br /> 2 = AS_ROW_END<br />5 = AS_TRANSACTION_ID_START<br />6 = AS_TRANSACTION_ID_END<br />7 = AS_SEQUENCE_NUMBER_START<br />8 = AS_SEQUENCE_NUMBER_END<br /><br /> For more information, see [Temporal Tables &#40;Relational databases&#41;](../../relational-databases/tables/temporal-tables.md).|
68-
|generated_always_type_desc|**nvarchar(60)**|**Applies to**: [!INCLUDE[sssql16-md](../../includes/sssql16-md.md)] and later, [!INCLUDE[ssSDS_md](../../includes/sssds-md.md)].<br /><br /> Textual description of `generated_always_type`'s value (always NOT_APPLICABLE for columns in system tables) <br /><br /> NOT_APPLICABLE<br /> AS_ROW_START<br /> AS_ROW_END<br /><br />**Applies to**: Starting with [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)], [!INCLUDE[ssSDS_md](../../includes/sssds-md.md)]<br /><br />AS_TRANSACTION_ID_START<br />AS_TRANSACTION_ID_END<br />AS_SEQUENCE_NUMBER_START<br />AS_SEQUENCE_NUMBER_END|
69-
|encryption_type|**int**|**Applies to**: [!INCLUDE[sssql16-md](../../includes/sssql16-md.md)] and later, [!INCLUDE[ssSDS_md](../../includes/sssds-md.md)].<br /><br /> Encryption type:<br /><br /> 1 = Deterministic encryption<br /><br /> 2 = Randomized encryption|
70-
|encryption_type_desc|**nvarchar(64)**|**Applies to**: [!INCLUDE[sssql16-md](../../includes/sssql16-md.md)] and later, [!INCLUDE[ssSDS_md](../../includes/sssds-md.md)].<br /><br /> Encryption type description:<br /><br /> RANDOMIZED<br /><br /> DETERMINISTIC|
71-
|encryption_algorithm_name|**sysname**|**Applies to**: [!INCLUDE[sssql16-md](../../includes/sssql16-md.md)] and later, [!INCLUDE[ssSDS_md](../../includes/sssds-md.md)].<br /><br /> Name of encryption algorithm.<br /><br /> Only AEAD_AES_256_CBC_HMAC_SHA_512 is supported.|
72-
|column_encryption_key_id|**int**|**Applies to**: [!INCLUDE[sssql16-md](../../includes/sssql16-md.md)] and later, [!INCLUDE[ssSDS_md](../../includes/sssds-md.md)].<br /><br /> ID of the CEK.|
73-
|column_encryption_key_database_name|**sysname**|**Applies to**: [!INCLUDE[sssql16-md](../../includes/sssql16-md.md)] and later, [!INCLUDE[ssazuresynapse-md](../../includes/sssds-md.md)].<br /><br /> The name of the database where the column encryption key exists if different than the database of the column. `NULL` if the key exists in the same database as the column.|
74-
|is_hidden|**bit**|**Applies to**: [!INCLUDE [sssql16-md](../../includes/sssql16-md.md)] and later, [!INCLUDE[ssSDS_md](../../includes/sssds-md.md)].<br /><br /> Indicates if the column is hidden:<br /><br /> 0 = regular, not-hidden, visible column<br /><br /> 1 = hidden column|
75-
|is_masked|**bit**|**Applies to**: [!INCLUDE [sssql16-md](../../includes/sssql16-md.md)] and later, [!INCLUDE[ssSDS_md](../../includes/sssds-md.md)].<br /><br /> Indicates if the column is masked by a dynamic data masking:<br /><br /> 0 = regular, not-masked column<br /><br /> 1 = column is masked|
76-
|graph_type |**int** |Internal column with a set of values. The values are between 1-8 for graph columns and `NULL` for others. |
77-
|graph_type_desc |**nvarchar(60)** |internal column with a set of values |
78-
|is_data_deletion_filter_column|**bit**|**Applies to**: Azure SQL Edge. Indicates if the column is the data retention filter column for the table.|
79-
|ledger_view_column_type|**tinyint**|**Applies to**: Starting with [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)], [!INCLUDE[ssSDS_md](../../includes/sssds-md.md)].<br /><br /> If not NULL, indicates the type of a column in a ledger view:<br /><br /> 1 = TRANSACTION_ID<br /> 2 = SEQUENCE_NUMBER<br /> 3 = OPERATION_TYPE<br /> 4 = OPERATION_TYPE_DESC<br/><br/>For more information on database ledger, see [Ledger](/azure/azure-sql/database/ledger-overview).|
80-
|ledger_view_column_type_desc|**nvarchar(60)**|**Applies to**: Starting with [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)], [!INCLUDE[ssSDS_md](../../includes/sssds-md.md)].<br /><br /> If not NULL, contains a textual description of the the type of a column in a ledger view:<br /><br /> TRANSACTION_ID<br /> SEQUENCE_NUMBER<br /> OPERATION_TYPE<br /> OPERATION_TYPE_DESC|
81-
|is_dropped_ledger_table_column|**bit**|**Applies to**: Starting with [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)], [!INCLUDE[ssSDS_md](../../includes/sssds-md.md)].<br /><br /> Indicates a ledger table column that has been dropped.|
24+
Returns a row for each column of an object that has columns, such as views or tables. The following list contains the object types that have columns:
8225

83-
## Permissions
26+
- Table-valued assembly functions (FT)
27+
- Inline table-valued SQL functions (IF)
28+
- Internal tables (IT)
29+
- System tables (S)
30+
- Table-valued SQL functions (TF)
31+
- User tables (U)
32+
- Views (V)
8433

85-
[!INCLUDE[ssCatViewPerm](../../includes/sscatviewperm-md.md)] For more information, see [Metadata Visibility Configuration](../../relational-databases/security/metadata-visibility-configuration.md).
86-
87-
## See Also
34+
| Column name | Data type | Description |
35+
| --- | --- | --- |
36+
| `object_id` | **int** | ID of the object to which this column belongs. |
37+
| `name` | **sysname** | Name of the column. Is unique within the object. |
38+
| `column_id` | **int** | ID of the column. Is unique within the object. Column IDs might not be sequential. |
39+
| `system_type_id` | **tinyint** | ID of the system type of the column. |
40+
| `user_type_id` | **int** | ID of the type of the column as defined by the user. To return the name of the type, join to the [sys.types](sys-types-transact-sql.md) catalog view on this column. |
41+
| `max_length` | **smallint** | Maximum length (in bytes) of the column.<br /><br />`-1` = Column data type is **varchar(max)**, **nvarchar(max)**, **varbinary(max)**, or **xml**.<br /><br />For **text**, **ntext**, and **image** columns, the max_length value is `16` (representing the 16-byte pointer only) or the value set by `sp_tableoption 'text in row'`. |
42+
| `precision` | **tinyint** | Precision of the column if numeric-based; otherwise, `0`. |
43+
| `scale` | **tinyint** | Scale of column if numeric-based; otherwise, `0`. |
44+
| `collation_name` | **sysname** | Name of the collation of the column if character-based; otherwise `NULL`. |
45+
| `is_nullable` | **bit** | `1` = Column is nullable<br />`0` = Column isn't nullable |
46+
| `is_ansi_padded` | **bit** | `1` = Column uses `ANSI_PADDING ON` behavior if character, binary, or variant<br /><br />`0` = Column isn't character, binary, or variant |
47+
| `is_rowguidcol` | **bit** | `1` = Column is a declared `ROWGUIDCOL` |
48+
| `is_identity` | **bit** | `1` = Column has identity values |
49+
| `is_computed` | **bit** | `1` = Column is a computed column |
50+
| `is_filestream` | **bit** | `1` = Column is a FILESTREAM column |
51+
| `is_replicated` | **bit** | `1` = Column is replicated |
52+
| `is_non_sql_subscribed` | **bit** | `1` = Column has a non-SQL Server subscriber |
53+
| `is_merge_published` | **bit** | `1` = Column is merge-published |
54+
| `is_dts_replicated` | **bit** | `1` = Column is replicated by using [!INCLUDE [ssIS](../../includes/ssis-md.md)] |
55+
| `is_xml_document` | **bit** | `1` = Content is a complete XML document<br /><br />`0` = Content is a document fragment, or the column data type isn't **xml** |
56+
| `xml_collection_id` | **int** | Nonzero if the data type of the column is **xml** and the XML is typed. The value is the ID of the collection containing the validating XML schema namespace of the column<br /><br />`0` = No XML schema collection |
57+
| `default_object_id` | **int** | ID of the default object, regardless of whether it's a stand-alone object [sp_bindefault](../system-stored-procedures/sp-bindefault-transact-sql.md), or an inline, column-level `DEFAULT` constraint. The parent_object_id column of an inline column-level default object is a reference back to the table itself.<br /><br />`0` = No default |
58+
| `rule_object_id` | **int** | ID of the stand-alone rule bound to the column by using `sys.sp_bindrule.`<br /><br />`0` = No stand-alone rule. For column-level `CHECK` constraints, see [sys.check_constraints](sys-check-constraints-transact-sql.md). |
59+
| `is_sparse` | **bit** | `1` = Column is a sparse column. For more information, see [Use sparse columns](../tables/use-sparse-columns.md). |
60+
| `is_column_set` | **bit** | `1` = Column is a column set. For more information, see [Use sparse columns](../tables/use-sparse-columns.md). |
61+
| `generated_always_type` | **tinyint** | Identifies when the column value is generated (is always `0` for columns in system tables).<br /><br />**Applies to**: [!INCLUDE [sssql16-md](../../includes/sssql16-md.md)] and later versions, and [!INCLUDE [ssSDS_md](../../includes/sssds-md.md)].<br /><br />`0` = `NOT_APPLICABLE`<br />`1` = `AS_ROW_START`<br />`2` = `AS_ROW_END`<br /><br />**Applies to**: [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)] and later versions, and [!INCLUDE [ssSDS_md](../../includes/sssds-md.md)].<br /><br />`5` = `AS_TRANSACTION_ID_START`<br />`6` = `AS_TRANSACTION_ID_END`<br />`7` = `AS_SEQUENCE_NUMBER_START`<br />`8` = `AS_SEQUENCE_NUMBER_END`<br /><br />For more information, see [Temporal Tables (Relational databases)](../tables/temporal-tables.md). |
62+
| `generated_always_type_desc` | **nvarchar(60)** | Textual description of the `generated_always_type` value (always `NOT_APPLICABLE` for columns in system tables)<br /><br />**Applies to**: [!INCLUDE [sssql16-md](../../includes/sssql16-md.md)] and later versions, and [!INCLUDE [ssSDS_md](../../includes/sssds-md.md)].<br /><br />`NOT_APPLICABLE`<br />`AS_ROW_START`<br />`AS_ROW_END`<br /><br />**Applies to**: [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)] and later versions, and [!INCLUDE [ssSDS_md](../../includes/sssds-md.md)].<br /><br />`AS_TRANSACTION_ID_START`<br />`AS_TRANSACTION_ID_END`<br />`AS_SEQUENCE_NUMBER_START`<br />`AS_SEQUENCE_NUMBER_END` |
63+
| `encryption_type` | **int** | Encryption type:<br /><br />`1` = Deterministic encryption<br />`2` = Randomized encryption<br /><br />**Applies to**: [!INCLUDE [sssql16-md](../../includes/sssql16-md.md)] and later versions, and [!INCLUDE [ssSDS_md](../../includes/sssds-md.md)] |
64+
| `encryption_type_desc` | **nvarchar(64)** | Encryption type description:<br /><br />`RANDOMIZED`<br />`DETERMINISTIC`<br /><br />**Applies to**: [!INCLUDE [sssql16-md](../../includes/sssql16-md.md)] and later versions, and [!INCLUDE [ssSDS_md](../../includes/sssds-md.md)] |
65+
| `encryption_algorithm_name` | **sysname** | Name of encryption algorithm. Only `AEAD_AES_256_CBC_HMAC_SHA_512` is supported.<br /><br />**Applies to**: [!INCLUDE [sssql16-md](../../includes/sssql16-md.md)] and later versions, and [!INCLUDE [ssSDS_md](../../includes/sssds-md.md)] |
66+
| `column_encryption_key_id` | **int** | ID of the column encryption key (CEK).<br /><br />**Applies to**: [!INCLUDE [sssql16-md](../../includes/sssql16-md.md)] and later versions, and [!INCLUDE [ssSDS_md](../../includes/sssds-md.md)] |
67+
| `column_encryption_key_database_name` | **sysname** | The name of the database where the column encryption key exists if different than the database of the column. `NULL` if the key exists in the same database as the column.<br /><br />**Applies to**: [!INCLUDE [sssql16-md](../../includes/sssql16-md.md)] and later versions, and [!INCLUDE [ssazuresynapse-md](../../includes/sssds-md.md)] |
68+
| `is_hidden` | **bit** | Indicates if the column is hidden:<br /><br />`0` = regular, not-hidden, visible column<br />`1` = hidden column<br /><br />**Applies to**: [!INCLUDE [sssql16-md](../../includes/sssql16-md.md)] and later versions, and [!INCLUDE [ssSDS_md](../../includes/sssds-md.md)] |
69+
| `is_masked` | **bit** | Indicates if the column is masked by dynamic data masking:<br /><br />`0` = regular, not-masked column<br />`1` = column is masked<br /><br />**Applies to**: [!INCLUDE [sssql16-md](../../includes/sssql16-md.md)] and later versions, and [!INCLUDE [ssSDS_md](../../includes/sssds-md.md)] |
70+
| `graph_type` | **int** | Internal column with a set of values. The values are between `1` and `8` for graph columns, and `NULL` for others. |
71+
| `graph_type_desc` | **nvarchar(60)** | [!INCLUDE [ssinternalonly-md](../../includes/ssinternalonly-md.md)] |
72+
| `is_data_deletion_filter_column` | **bit** | Indicates if the column is the data retention filter column for the table.<br /><br />**Applies to**: Azure SQL Edge |
73+
| `ledger_view_column_type` | **int** | If not `NULL`, indicates the type of a column in a ledger view:<br /><br />`1` = `TRANSACTION_ID`<br />`2` = `SEQUENCE_NUMBER`<br />`3` = `OPERATION_TYPE`<br />`4` = `OPERATION_TYPE_DESC`<br /><br />For more information, see [Ledger overview](/azure/azure-sql/database/ledger-overview).<br /><br />**Applies to**: [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)] and later versions, and [!INCLUDE [ssSDS_md](../../includes/sssds-md.md)] |
74+
| `ledger_view_column_type_desc` | **nvarchar(60)** | If not `NULL`, contains a textual description of the the type of a column in a ledger view:<br /><br />`TRANSACTION_ID`<br />`SEQUENCE_NUMBER`<br />`OPERATION_TYPE`<br />`OPERATION_TYPE_DESC`<br /><br />**Applies to**: [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)] and later versions, and [!INCLUDE [ssSDS_md](../../includes/sssds-md.md)] |
75+
| `is_dropped_ledger_column` | **bit** | Indicates a ledger table column that was dropped.<br /><br />**Applies to**: [!INCLUDE [sssql22-md](../../includes/sssql22-md.md)] and later versions, and [!INCLUDE [ssSDS_md](../../includes/sssds-md.md)] |
8876

89-
[System Views &#40;Transact-SQL&#41;](../../t-sql/language-reference.md)
90-
[Object Catalog Views &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/object-catalog-views-transact-sql.md)
91-
[Catalog Views &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/catalog-views-transact-sql.md)
92-
[Querying the SQL Server System Catalog FAQ](../../relational-databases/system-catalog-views/querying-the-sql-server-system-catalog-faq.yml)
93-
[sys.all_columns &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/sys-all-columns-transact-sql.md)
94-
[sys.system_columns &#40;Transact-SQL&#41;](../../relational-databases/system-catalog-views/sys-system-columns-transact-sql.md)
77+
## Permissions
78+
79+
[!INCLUDE [ssCatViewPerm](../../includes/sscatviewperm-md.md)] For more information, see [Metadata Visibility Configuration](../security/metadata-visibility-configuration.md).
80+
81+
## Related content
82+
83+
- [System Views (Transact-SQL)](../../t-sql/language-reference.md)
84+
- [Object Catalog Views (Transact-SQL)](object-catalog-views-transact-sql.md)
85+
- [System catalog views (Transact-SQL)](catalog-views-transact-sql.md)
86+
- [Querying the SQL Server System Catalog FAQ](querying-the-sql-server-system-catalog-faq.yml)
87+
- [sys.all_columns (Transact-SQL)](sys-all-columns-transact-sql.md)
88+
- [sys.system_columns (Transact-SQL)](sys-system-columns-transact-sql.md)

0 commit comments

Comments
 (0)