Returns information about a column or procedure parameter.
COLUMNPROPERTY ( id , column , property )
Is an expression that contains the identifier (ID) of the table or procedure.
Is an expression that contains the name of the column or parameter.
Is an expression that contains the information to be returned for id, and can be any one of the following values.
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.
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.
The following example returns the length of the
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)
Help and Information
17 July 2006