⌘BABAKOV.NET Let's code!
100% [dark] [ru]

Adding Comments to Table Fields in MSSQL TSQL

To add a comment to a table field in MSSQL, use:

EXEC sp_addextendedproperty 
    @name = N\'MS_Description\', 
    @value = N\'Комментарий к полю таблицы\', 
    @level0type = N\'SCHEMA\', @level0name = N\'dbo\', -- Заменить \'dbo\' на название вашей схемы, если отличается
    @level1type = N\'TABLE\', @level1name = N\'YourTableName\', -- Заменить \'YourTableName\' на название вашей таблицы
    @level2type = N\'COLUMN\', @level2name = N\'YourColumnName\'; -- Заменить \'YourColumnName\' - на имя вашего столбца


To change a comment to a table field in MSSQL, use:

EXEC sp_updateextendedproperty 
    @name = N\'MS_Description\', 
    @value = N\'Updated description for the column.\', 
    @level0type = N\'SCHEMA\', @level0name = N\'dbo\', 
    @level1type = N\'TABLE\', @level1name = N\'YourTableName\', 
    @level2type = N\'COLUMN\', @level2name = N\'YourColumnName\';


To delete a comment to a table field in MSSQL, use:

EXEC sp_dropextendedproperty 
    @name = N\'MS_Description\', 
    @level0type = N\'SCHEMA\', @level0name = N\'dbo\', 
    @level1type = N\'TABLE\', @level1name = N\'YourTableName\', 
    @level2type = N\'COLUMN\', @level2name = N\'YourColumnName\';

Comments (0)

No comments yet.

Comments are closed for this post.