zoukankan      html  css  js  c++  java
  • sql server 2005 导出用户表数据字典(转载)

    -----------------------------------------------------
    --作用:用于sql server 2005 导出用户表数据字典
    --1 默认导出当前数据库中所有用户表(xtype = 'u')的数据字典;
    --2 可以在xtype = 'u'替换为如下所示语句xtype = 'u' and name in ('son','Person') 导出自定义的表的数据字典;
    --3 可以利用集成服务SSIS导出数据字典的excel文件,形成文档;
    ------------------------------------------------------
    select sysobjects.name as "表名",syscolumns.name as "字段名",
    case when systypes.name in ('binary','char','nchar') then (systypes.name + '(' + cast(syscolumns.prec as varchar(50)) + ')')
    when systypes.name in ('decimal','numeric') then (systypes.name + '(' + cast(syscolumns.prec as varchar(50)) + ',' + cast(syscolumns.scale as varchar(50)) + ')')
    when systypes.name in ('nvarchar','varchar','varbinary') then (case when syscolumns.prec = -1 then (systypes.name + '(MAX)') else (systypes.name + '(' + cast(syscolumns.prec as varchar(50)) + ')') end)
    else systypes.name end as "字段类型",
    syscomments.text as "默认值", case when syscolumns.isnullable = 1 then 'Y' else 'N' end as "能否为空",
     cast(sys.extended_properties.value as varchar(1024)) as "备注"
    from syscolumns inner join systypes on syscolumns.xtype = systypes.xtype left join sysobjects
    on syscolumns.id = sysobjects.id left outer join sys.extended_properties
    on ( sys.extended_properties.minor_id = syscolumns.colid and sys.extended_properties.major_id = syscolumns.id) left outer join syscomments
    on syscolumns.cdefault = syscomments.id where syscolumns.id in (select id from sysobjects where xtype = 'u') and (systypes.name <> 'sysname') order by sysobjects.name asc
    版权说明

      如果标题未标有<转载、转>等字则属于作者原创,欢迎转载,其版权归作者和博客园共有。
      作      者:温景良
      文章出处:http://wenjl520.cnblogs.com/  或  http://www.cnblogs.com/

  • 相关阅读:
    【POJ
    【OpenJ_Bailian
    【Aizu
    【OpenJ_Bailian
    leetcode-746-Min Cost Climbing Stairs(动态规划)
    leetcode-744-Find Smallest Letter Greater Than Target(改进的二分查找)
    leetcode-728-Self Dividing Numbers
    leetcode-717-1-bit and 2-bit Characters
    leetcode-697-Degree of an Array
    leetcode-682-Baseball Game
  • 原文地址:https://www.cnblogs.com/wenjl520/p/1317728.html
Copyright © 2011-2022 走看看