码迷,mamicode.com
首页 > 数据库 > 详细

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

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

标签:style   blog   http   color   数据   ar   2014   div   

导出的格式形如:

 

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

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

标签:style   blog   http   color   数据   ar   2014   div   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!