COLUMNPROPERTY (Transact-SQL)

Returns information about a column or procedure parameter.

Topic link iconTransact-SQL Syntax Conventions

Syntax

COLUMNPROPERTY ( id , column , property ) 

Arguments

  • id
    Is an expression that contains the identifier (ID) of the table or procedure.
  • column
    Is an expression that contains the name of the column or parameter.
  • property
    Is an expression that contains the information to be returned for id, and can be any one of the following values.

    Value

Return Types

int

Exceptions

Returns NULL on error or if a caller does not have permission to view the object.

In SQL Server 2005, a user can only view the metadata of securables that the user owns or on which the user has been granted permission. This means that metadata-emitting, built-in functions such as COLUMNPROPERTY may return NULL if the user does not have any permission on the object. For more information, see Metadata Visibility Configuration and Troubleshooting Metadata Visibility.

Remarks

When you check the deterministic property of a column, first test whether the column is a computed column. IsDeterministic returns NULL for noncomputed columns. Computed columns can be specified as index columns.

Examples

The following example returns the length of the LastName column.

USE AdventureWorks;
GO
SELECT COLUMNPROPERTY( OBJECT_ID('Person.Contact'),'LastName','PRECISION')AS 'Column Length';
GO

Here is the result set.

Column Length 
------------- 
50

(1 row(s) affected)

See Also

Reference

Metadata Functions (Transact-SQL)
OBJECTPROPERTY (Transact-SQL)
TYPEPROPERTY (Transact-SQL)

Help and Information

Getting SQL Server 2005 Assistance

Change History

Release History

17 July 2006

New content:
  • Added the "Exceptions" section.