EJC EJC - 1 year ago 125
SQL Question

adding a column description

Does anyone know how to add a description to a SQL Server column by running a script? I know you can add a description when you create the column using SQL Server Management Studio.

How can I script this so when my SQL scripts create the column, a description for the column is also added?

Answer Source

I'd say you will probably want to do it using the sp_addextendedproperty stored proc.

Microsoft has some good documentation on it but you can also look at this link:


Try this:

EXEC sp_addextendedproperty 
    @name = N'MS_Description', @value = 'Hey, here is my description!',
    @level0type = N'Schema',   @level0name = 'yourschema',
    @level1type = N'Table',    @level1name = 'YourTable',
    @level2type = N'Column',   @level2name = 'yourColumn';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download