首页 > 数据库技术 > 详细

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

时间:2014-08-18 14:15:42      阅读:363      评论:0      收藏:0      [点我收藏+]

导出的格式形如:

 

bubuko.com,布布扣

 

use ppdai_vd;
go

SELECT  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_id
left join   sys.extended_properties d on b.object_id=d.major_id and b.column_id=d.minor_id
left 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

 

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

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

原文:http://www.cnblogs.com/dingqin0525/p/3919389.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!