首页 > 代码库 > 维护数字字典时,批量导入数据库的列注释、类型等相关信息
维护数字字典时,批量导入数据库的列注释、类型等相关信息
导出的格式形如:
use ppdai_vd;goSELECT ‘ppdai_vd‘ AS 数据库名, a.name as ‘表名‘ , isnull(e.value,‘‘) as ‘表注释‘, CONVERT(VARCHAR(19), a.create_date ,23) AS ‘创建时间‘, b.column_id as ‘字段序号‘, b.name as ‘字段名‘, ‘数据类型‘ = case when c.name IN (‘varchar‘,‘nvarchar‘,‘varbinary‘) and b.max_length =-1 then c.name +‘(max)‘ when c.name in (‘varchar‘,‘nvarchar‘,‘char‘,‘nchar‘,‘binary‘,‘varbinary‘) and b.max_length>0 then c.name +‘(‘+CAST(b.max_length AS VARCHAR)+‘)‘ else c.name end ,isnull(d.[value],‘‘) as ‘字段注释‘ FROM sys.objects a inner join sys.columns b on a.object_id=b.object_id and a.type=‘U‘ left join sys.types c on b.user_type_id = c.user_type_idleft join sys.extended_properties d on b.object_id=d.major_id and b.column_id=d.minor_idleft join sys.extended_properties e on a.object_id =e.major_id and e.minor_id=0--where a.object_id = object_id(‘user‘) order by a.name,b.column_id
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。