Returns the optimal set of columns that uniquely identify a row in the table and columns that are automatically updated when any value in the row is updated by a transaction.
sp_special_columns table_name [, table_owner] [, table_qualifier] [, col_type] [, scope] [, nullable]
where
In Microsoft SQL Server, if the current user owns a table with the specified name, that table's columns are returned. If the table_owner is not specified and the current user does not own a table with the specified table_name, this procedure will look for a table with the specified table_name owned by the database owner. If one exists, that table's columns are returned.
The sp_special_columns stored procedure is equivalent to SQLSpecialColumns in ODBC. The results returned are ordered by SCOPE.
This is the results set:
Column | Datatype | Description |
---|---|---|
SCOPE | int | Is the actual scope of the row ID. Can be 0, 1, or 2. SQL Server always returns 0. This field will always return a value.
0 SQL_SCOPE_CURROW. The row
1 SQL_SCOPE_TRANSACTION.
2 SQL_SCOPE_SESSION. The |
COLUMN_NAME | varchar(32) | Is the name of the column, for each column of the TABLE_NAME returned. In Microsoft SQL Server, this column represents the column name as listed in the syscolumns table. This field will always return a value. |
DATA_TYPE | smallint | Is an ODBC SQL datatype. |
TYPE_NAME | varchar(13) | Is a data source-dependent datatype name; for example, 'CHAR', 'VARCHAR', 'MONEY', or 'TEXT'. |
PRECISION | int | Is the precision of the column on the data source. This field will always return a value. |
LENGTH | int | Is the length, in bytes, required for the datatype in its binary form in the data source. For example, 10 for CHAR(10), 4 for INTEGER, and 2 for SMALLINT. |
SCALE | smallint | Is the scale of the column on the data source. NULL is returned for datatypes where scale is not applicable. |
PSEUDO_COLUMN | smallint | Indicates whether the column is a pseudo column. SQL Server 6.0 always returns 2. Can be:
0 SQL_PC_UNKNOWN |