Tuesday, May 29, 2012

Microsoft SQL Server:Add Table/Columns Description



Use sys.sp_addextendedproperty to add Description to the tables and columns.

E.g.

For Table Description,


EXEC sys.sp_addextendedproperty
@name = N'MS_Description',
@value = N'Put your Table Comments Here ',
@level0type = N'SCHEMA', @level0name = 'dbo',
@level1type = N'TABLE',  @level1name = 'TableName';
GO


**dbo is database schema.you may your own schema where objects reside.

For Columns Description,

EXEC sys.sp_addextendedproperty
@name=N'MS_Description',
@value=N'Put your Comment here' ,
@level0type=N'SCHEMA',@level0name=N'dbo',
@level1type=N'TABLE',@level1name=N'TableName',
@level2type=N'COLUMN',@level2name=N'ColumnName1'
GO

EXEC sys.sp_addextendedproperty
@name=N'MS_Description',
@value=N'Put your Comment here' ,
@level0type=N'SCHEMA',@level0name=N'dbo',
@level1type=N'TABLE',@level1name=N'TableName',
@level2type=N'COLUMN',@level2name=N'ColumnName2'
GO