sql server 为表格添加注释语句(SQL server adds comment statements to tables)

1、为表格添加注释

EXEC sys.sp_addextendedproperty @name=N'MS_Description', 
@value=N'表格注释内容' , 
@level0type=N'SCHEMA',@level0name=N'选择dbo或者guest', 
@level1type=N'TABLE',@level1name=N'表格名称'

// 例如:
EXEC sys.sp_addextendedproperty @name=N'MS_Description', 
@value=N'测试表格' , 
@level0type=N'SCHEMA',@level0name=N'dbo', 
@level1type=N'TABLE',@level1name=N'test_table'

2、为表格中的字段添加注释

EXEC sys.sp_addextendedproperty @name=N'MS_Description',
@value=N'字段注释内容' , 
@level0type=N'SCHEMA',@level0name=N'选择dbo或者guest',
@level1type=N'TABLE',@level1name=N'字段所属表格名称',
@level2type=N'COLUMN',@level2name=N'字段名称';

// 例如:
EXEC sys.sp_addextendedproperty @name=N'MS_Description',
@value=N'自增ID' , 
@level0type=N'SCHEMA',@level0name=N'dbo',
@level1type=N'TABLE',@level1name=N'test_table',
@level2type=N'COLUMN',@level2name=N'tt_id';
————————

1. Add notes to the table

EXEC sys.sp_addextendedproperty @name=N'MS_Description', 
@value=N'表格注释内容' , 
@level0type=N'SCHEMA',@level0name=N'选择dbo或者guest', 
@level1type=N'TABLE',@level1name=N'表格名称'

// 例如:
EXEC sys.sp_addextendedproperty @name=N'MS_Description', 
@value=N'测试表格' , 
@level0type=N'SCHEMA',@level0name=N'dbo', 
@level1type=N'TABLE',@level1name=N'test_table'

2. Add comments to fields in the table

EXEC sys.sp_addextendedproperty @name=N'MS_Description',
@value=N'字段注释内容' , 
@level0type=N'SCHEMA',@level0name=N'选择dbo或者guest',
@level1type=N'TABLE',@level1name=N'字段所属表格名称',
@level2type=N'COLUMN',@level2name=N'字段名称';

// 例如:
EXEC sys.sp_addextendedproperty @name=N'MS_Description',
@value=N'自增ID' , 
@level0type=N'SCHEMA',@level0name=N'dbo',
@level1type=N'TABLE',@level1name=N'test_table',
@level2type=N'COLUMN',@level2name=N'tt_id';