首页 > 代码库 > 维护数字字典时,批量导入数据库的列注释、类型等相关信息

维护数字字典时,批量导入数据库的列注释、类型等相关信息

导出的格式形如:

 

 

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