sql-server - 在 SQL Server 中访问表注释
问题描述
我正在将数据库从 Oracle 迁移到 SQL Server。在 Oracle 中,可以使用 all_tab_comments 表读取表注释。在 SQL Server 中找不到执行此操作的方法。怎么能处理这个?
解决方案
select t.id as "object_id",
t.name as "TableName",
schema_name(t2.schema_id) as "Schema",
t3.name as "Column",
t4.value as "Column description",
t5.value as "Table description"
from sysobjects t
inner join sys.tables t2 on t2.object_id = t.id
inner join sys.columns t3 on t3.object_id = t.id
left join sys.extended_properties t4 on t4.major_id = t.id
and t4.name = 'MS_Description'
and t4.minor_id = t3.column_id
left join sys.extended_properties t5 on t5.major_id = t.id
and t5.name = 'MS_Description'
and t5.minor_id = 0
where t.name = 'YourTableName'
and t2.schema_id = schema_id('YourSchemaName')
推荐阅读
- java - 使用 POI 更改文本框中部分文本的字体颜色
- linux - Logstash docker 容器填满 overley2 文件夹中的根磁盘空间
- c# - 控制器中的获取请求不起作用,并说找不到 http 资源
- c# - 如何在 ushort 数组中读取图像的像素数据并将此 ushort 数组导出为 c# 中的二进制文件
- laravel - Laravel 中的 User::create(~) 是什么?
- css - @media 查询仅适用于该宽度
- sql-server - 将数据从一个数据库表传输到另一个数据库表
- macos - macOS Sierra Apache 2:全局设置“ServerName”指令以禁止显示此消息
- c++ - 如何在 MSVC 的原始字符串文字中使用 Unicode 符号/表情符号
- vimeo - 无效状态错误。Vimeo 视频播放正常但抛出异常