给SQLServer数据库添加表说明和表字段说明

1. 给表添加说明:

exec sp_addextendedproperty @name = N'Description_A'
  ,@value = N'雇员表'
  ,@level0type='SCHEMA'
  ,@level0name = dbo --結構名
  ,@level1type='table'
  ,@level1name='Employee' --表名

--獲取添加的表描述信息
select * from fn_listextendedproperty(null,'SCHEMA','dbo','table','Employee',null,null)

GO

2. 给表的字段添加说明:

CREATE TABLE [dbo].[Answers](
 [RequestID] [int] NULL,
 [CustomerID] [int] NULL,
 [CustomerCompany] [varchar](100) COLLATE Chinese_PRC_CI_AS NULL,
 [AnswerContent] [varchar](5000) COLLATE Chinese_PRC_CI_AS NULL,
 [AddTime] [smalldatetime] NULL
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'百科问答ID' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Answers', @level2type=N'COLUMN', @level2name=N'RequestID'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'提问用户ID' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Answers', @level2type=N'COLUMN', @level2name=N'CustomerID'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户公司名称' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Answers', @level2type=N'COLUMN', @level2name=N'CustomerCompany'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'提问内容' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Answers', @level2type=N'COLUMN', @level2name=N'AnswerContent'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'提问时间' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Answers', @level2type=N'COLUMN', @level2name=N'AddTime'


 

 

posted @ 2009-12-24 11:08  飘渺峰  阅读(1578)  评论(0编辑  收藏  举报