That depends on what you mean by "comment". If you want to add descriptive text to a column, you can set the Column Description
using SQL Server Management Studio:
- Table Column Properties (SQL Server Management Studio)
To set the description programmatically, you can use the sp_addextendedproperty, sp_updateextendedproperty and sp_dropextendedproperty stored procedures. Example:
EXEC sp_addextendedproperty
@name = N'MS_Description', @value = 'This is the description of my column',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'MyTable',
@level2type = N'Column', @level2name = 'MyColumn'
I admit that the syntax is a bit inconvenient -- the following blog post contains stored procedures that make this process a bit easier:
- T-SQL Tuesday: Easy Extended Properties