Returns the optimal set of columns that uniquely identify a row in the table. Also returns columns that are automatically updated when any value in the row is updated by a transaction.
sp_special_columns [@name =] 'name'
[,[owner =] 'owner']
[,[@qualifier =] 'qualifier']
[,[@col_type =] 'col_type']
[,[@scope =] 'scope']
[,[@nullable =] 'nullable']
[,[@ODBCVer =] 'ODBCVer']
In Microsoft® SQL Server™, if the current user owns a table with the specified name, the columns of that table are returned. If owner is not specified and the current user does not own a table of the specified name, this procedure looks for a table of the specified name owned by the owner of the database. If the table exists, its columns are returned.
None
Column name | Data type | Description |
---|---|---|
SCOPE | smallint | Actual scope of the row ID. Can be 0, 1, or 2. SQL Server always returns 0. This field always returns a value.
0 = SQL_SCOPE_CURROW. The row ID is guaranteed to be valid only while positioned on that row. A later reselect using the row ID may not return a row if the row was updated or deleted by another transaction. 1 = SQL_SCOPE_TRANSACTION. The row ID is guaranteed to be valid for the duration of the current transaction. 2 = SQL_SCOPE_SESSION. The row ID is guaranteed to be valid for the duration of the session (across transaction boundaries). |
COLUMN_NAME | sysname | Column name for each column of the table returned. This field always returns a value. |
DATA_TYPE | smallint | ODBC SQL data type. |
TYPE_NAME | sysname | Data source-dependent data type name; for example, char, varchar, money, or text. |
PRECISION | int | Precision of the column on the data source. This field always returns a value. |
LENGTH | int | Length, in bytes, required for the data type in its binary form in the data source, for example, 10 for char(10), 4 for integer, and 2 for smallint. |
SCALE | smallint | Scale of the column on the data source. NULL is returned for data types for which scale is not applicable. |
PSEUDO_COLUMN | smallint | Indicates whether the column is a pseudocolumn. SQL Server always returns 2: 0 = SQL_PC_UNKNOWN 1 = SQL_PC_PSEUDO 2 = SQL_PC_NOT_PSEUDO |
sp_special_columns is equivalent to SQLSpecialColumns in ODBC. The results returned are ordered by SCOPE.
Execute permissions default to the public role.