Returns the column information, one row per column, for the specified linked server tables. sp_columns_ex returns column information for only the specific column if column is specified.
sp_columns_ex [ @table_server = ] 'table_server' [ , [ @table_name = ] 'table_name' ] [ , [ @table_schema = ] 'table_schema' ] [ , [ @table_catalog = ] 'table_catalog' ] [ , [ @column_name = ] 'column' ] [ , [ @ODBCVer = ] 'ODBCVer' ]
Table or view qualifier name. Various DBMS products support three-part naming for tables (qualifier.owner.name). In SQL Server 2008 and SQL Server 2005, this column represents the database name. In some products, it represents the server name of the table's database environment. This field can be NULL.
Table or view owner name. In SQL Server, this column represents the name of the database user that created the table. This field always returns a value.
Table or view name. This field always returns a value.
Column name, for each column of the TABLE_NAME returned. This field always returns a value.
Integer value that correspond to ODBC type indicators. If this is a data type that cannot be mapped to an ODBC type, this value is NULL. The native data type name is returned in the TYPE_NAME column.
String representing a data type. The underlying DBMS presents this data type name.
Number of significant digits. The return value for the PRECISION column is in base 10.
Transfer size of the data.1
Number of digits to the right of the decimal point.
Is the base for numeric data types.
1 = NULL is possible.
0 = NOT NULL.
This field always returns NULL.
Default value of the column.
SQL Server 2008 and SQL Server 2005 differ from SQL Server 2000 in the way they decode and store SQL expressions in the catalog metadata. The semantics of the decoded expression are equivalent to the original text; however, there are no syntactic guarantees. For example, white spaces are removed from the decoded expression. For more information, see, Behavior Changes to Database Engine Features in SQL Server 2008.
Value of the SQL data type as it appears in the TYPE field of the descriptor. This column is the same as the DATA_TYPE column, except for the datetime and SQL-92 interval data types. This column always returns a value.
Subtype code for datetime and SQL-92 interval data types. For other data types, this column returns NULL.
Maximum length in bytes of a character or integer data type column. For all other data types, this column returns NULL.
Ordinal position of the column in the table. The first column in the table is 1. This column always returns a value.
Nullability of the column in the table. ISO rules are followed to determine nullability. An ISO SQL-compliant DBMS cannot return an empty string.
YES = Column can include NULLS.
NO = Column cannot include NULLS.
This column returns a zero-length string if nullability is unknown.
The value returned for this column is different from the value returned for the NULLABLE column.
SQL Server data type, used by extended stored procedures. For more information, see Data Types (Database Engine).
For more information, see the Microsoft ODBC documentation.
sp_columns_ex is executed by querying the COLUMNS rowset of the IDBSchemaRowset interface of the OLE DB provider corresponding to table_server. The table_name, table_schema, table_catalog, and column parameters are passed to this interface to restrict the rows returned.
sp_columns_ex returns an empty result set if the OLE DB provider of the specified linked server does not support the COLUMNS rowset of the IDBSchemaRowset interface.
sp_columns_ex follows the requirements for delimited identifiers. For more information, see Delimited Identifiers (Database Engine).
The following example returns the data type of the Title column of the HumanResources.Employee table in the AdventureWorks database on the linked server Seattle1.
EXEC sp_columns_ex 'Seattle1', 'Employee', 'HumanResources', 'AdventureWorks', 'Title';