zoukankan      html  css  js  c++  java
  • 查询表结构视图

    /****** Object: View [dbo].[ViewTable] Script Date: 09/06/2016 11:12:28 ******/

    SET ANSI_NULLS ON
    GO

    SET QUOTED_IDENTIFIER ON
    GO

    -- =============================================
    -- Author: gengc
    -- Create date: <2012-12-29>
    -- Description: <查看表结构>
    -- =============================================

    CREATE View ViewTable
    as
    select
    obj.name as 'TableName'
    ,c.name as 'CName'
    ,isnull(etp.value,'') AS 'CDesc'
    ,t.name as '字段类型'
    ,c.Length as '占用字节'
    ,ColumnProperty(c.id,c.name,'PRECISION') as '长度'
    ,isnull(ColumnProperty(c.id,c.name,'Scale'),0) as '小数位数'
    ,case(c.isnullable) when '1' then '√' else '' end as '是否为空'
    ,ISNULL(cm.text,'') as '默认值'
    ,case(
    (select 1 from sysobjects where xtype='PK' and parent_obj=c.id and name in (
    select name from sysindexes where indid in(
    select indid from sysindexkeys where id = c.id and colid=c.colid)))
    ) when '1' then 'Y' else '' end as '是否主键'
    ,case(ColumnProperty(c.id,c.name,'IsIdentity')) when '1' then 'Y' else '' end as '自动增长'
    from syscolumns c
    inner join systypes t on c.xusertype = t.xusertype
    left join sys.extended_properties etp on etp.major_id = c.id and etp.minor_id = c.colid and etp.name ='MS_Description'
    left join syscomments cm on c.cdefault=cm.id
    left join sysobjects obj on c.id=obj.id

    GO

  • 相关阅读:
    解决html2canvas插件object-fit样式不生效问题
    七牛云视频获取视频封面和缩略图
    实现一个简单拖拽
    elementui遮罩层下方内容禁止滑动
    echars适配代码
    修改vue项目页面的title
    用div实现textarea
    判断手机端和pc端
    angular的跨域
    angular的文件上传
  • 原文地址:https://www.cnblogs.com/chengeng/p/5845028.html
Copyright © 2011-2022 走看看