sqlserver批量更改所有表中相同字段的注释
时间: 2023-08-22 13:05:20 浏览: 47
你可以使用以下 SQL 语句批量更改所有表中相同字段的注释:
```
EXEC sp_MSforeachtable @command1="print '?'", @command2="EXEC sp_addextendedproperty 'MS_Description', 'Your comment here', 'user', dbo, 'table', '?'"
```
将 `Your comment here` 替换为你想要的注释内容即可。这个语句会遍历数据库中的所有表,并为每个表的指定字段添加注释。如果你只想对特定的表进行操作,可以在 `@command1` 参数中指定表名,例如:
```
EXEC sp_MSforeachtable @command1="print '?' WHERE '?' = 'YourTableName'", @command2="EXEC sp_addextendedproperty 'MS_Description', 'Your comment here', 'user', dbo, 'table', '?' WHERE '?' = 'YourTableName'"
```
将 `YourTableName` 替换为你想要操作的表名即可。