Schema: How do I show the description property of a column?
SQL Server 2000
You can add a description in the Enterprise Manager GUI, or you could use this code:
Now, you can retrieve the values for all tables with the following code:
The commented AND in the WHERE clause is useful if you are only interested in all the columns in a single table, as opposed to all tables and all columns.
And if you only want all the columns in the database that have a description, change the outer join to an inner join:
SQL Server 2005
The sysproperties table is deprecated in SQL Server 2005, so the above technique will no longer work. Thankfully, they have added a system catalog view called sys.extended_properties, which works almost the same as the sysproperties table we are already familiar with.
Like the SQL Server 2000 example, you can change the code to only return columns in a single table, or all columns in the database that have a valid description.
In Access, you can get individual column descriptions using the following query from ASP:
Related ArticlesSchema: How do I list all the indexes in a database?
Schema: How do I list the databases on my server?
Schema: How do I show all the primary keys in a database?
Schema: How do I show all the triggers in a database?
Schema: How do I show the columns for a table?
Schema: How do I show the parameters for a function or stored procedure?
Schema: How do I show the stored procedures in a database?
Schema: How do I show the tables in a database?
Schema: How do I show the user-defined functions (UDFs) in a database?
Schema: How do I show the views in a SQL Server database?