我只是想知道如何在SQL Server中的现有表列中添加注释?看起来很简单,但我只是在第一个引发搜索引擎的5个结果中找不到任何内容.
编辑
我不想使用UI,而是知道SQL查询.
Pan*_*kaj 27
在SQL Server Management Studio中创建新表时,请参阅下面提到的屏幕截图,以便将描述添加到列中.
另一种以编程方式执行此操作的方法
EXEC sp_updateextendedproperty
@name = N'MS_Description', @value = 'Your description',
@level0type = N'Schema', @level0name = dbo,
@level1type = N'Table', @level1name = Your Table Name,
@level2type = N'Column', @level2name = Yuur Column Name;
Run Code Online (Sandbox Code Playgroud)
Hei*_*nzi 12
这取决于你的意思"评论".如果要将描述性文本添加到列,可以Column Description
使用SQL Server Management Studio进行设置:
要以编程方式设置描述,可以使用sp_addextendedproperty,sp_updateextendedproperty和sp_dropextendedproperty存储过程.例:
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'
Run Code Online (Sandbox Code Playgroud)
我承认语法有点不方便 - 以下博客文章包含使这个过程更容易的存储过程: