zoukankan      html  css  js  c++  java
  • 痛快-代码生成所用SQL

    查询所有表及注释

    SELECT  so.name ,
            ep.[value] AS [description]
    FROM    sysobjects so ( NOLOCK )
            LEFT JOIN sys.extended_properties ep ( NOLOCK ) ON ep.major_id = so.id
                                                               AND ep.minor_id = 0
    WHERE   so.[type] = 'U'
    ORDER BY so.name

    查询表中所有字段及注释

    SELECT  c.name ,
            t.name AS [type] ,
            c.max_length AS maxLength ,
            c.is_nullable AS isNullable ,
            ( SELECT    COUNT(1)
              FROM      sys.identity_columns ic ( NOLOCK )
              WHERE     ic.[object_id] = c.[object_id]
                        AND ic.column_id = c.column_id
            ) AS isIdentity ,
            ( SELECT    VALUE
              FROM      sys.extended_properties ep ( NOLOCK )
              WHERE     ep.major_id = c.object_id
                        AND ep.minor_id = c.column_id
            ) AS [description]
    FROM    sys.[columns] c ( NOLOCK )
            INNER JOIN sys.tables ts ( NOLOCK ) ON ts.[object_id] = c.[object_id]
            INNER JOIN sys.types t ( NOLOCK ) ON t.system_type_id = c.system_type_id
            INNER JOIN systypes st ( NOLOCK ) ON st.name = t.name
                                                 AND st.name <> 'sysname'
            INNER JOIN sysusers su ( NOLOCK ) ON st.uid = su.uid
                                                 AND su.name = 'sys'
    WHERE   ts.name = 'Question'
    ORDER BY c.column_id ASC
  • 相关阅读:
    Ceph相关
    Redis学习
    docker mysql
    WebSocket学习与使用
    nginx学习与使用
    python学习小记
    基数计数——HyperLogLog
    Swagger使用小记
    理解Java枚举类型
    Jenkins使用
  • 原文地址:https://www.cnblogs.com/tongkuai/p/3234529.html
Copyright © 2011-2022 走看看