• MSSQL 获取数据库字段类型


     1 SELECT
     2    col.name AS 列名,
     3    typ.name as 数据类型,
     4    col.max_length AS 占用字节数,
     5    col.precision AS 数字长度,
     6    col.scale AS 小数位数,
     7    col.is_nullable  AS 是否允许非空,
     8    col.is_identity  AS 是否自增,
     9    case when exists 
    10       ( SELECT 1 
    11         FROM 
    12           sys.indexes idx 
    13             join sys.index_columns idxCol 
    14             on (idx.object_id = idxCol.object_id)
    15          WHERE
    16             idx.object_id = col.object_id
    17             AND idxCol.index_column_id = col.column_id
    18             AND idx.is_primary_key = 1
    19        ) THEN 1 ELSE 0 END  AS 是否是主键,
    20   isnull(prop.[value],'-') AS 说明
    21 FROM
    22   sys.columns col 
    23     left join sys.types typ 
    24       on (col.system_type_id = typ.system_type_id)
    25     left join sys.extended_properties prop
    26       on (col.object_id = prop.major_id AND prop.minor_id = col.column_id)
    27 WHERE
    28   col.object_id =
    29     (SELECT object_id FROM sys.tables WHERE name = 'band')
  • 相关阅读:
    TF利用分布式队列控制线程
    非随机的抽样
    代码杂谈-split函数
    beta函数与置信度估计
    tensorflow模型
    SQL的技巧
    tensorflow输入数据处理
    flink学习
    Python
    通过淘宝IP地址库获取IP位置
  • 原文地址:https://www.cnblogs.com/smartsensor/p/3809975.html
Copyright © 2020-2023  润新知