• 获得SQL数据库信息


    下午没事从网上看些东西复制了下来,,,

     

    SELECT Name FROM Master..SysDatabases ORDER BY Name --获得所有数据库

    SELECT Name FROM [数据库名]..SysObjects Where XType='U' ORDER BY Name --获得数据库下的所有表

    select  name from  syscolumns where id=object_id(N'表名') --获得表里的所有字段

     

    --获取表字段名、类型、递增、描述

    select syscolumns.name as 字段,syscolumns.isnullable as 可否为空,systypes.name as SQL类型,

    ISNULL(sys.identity_columns.is_identity,0) as 递增,

    ISNULL(sys.extended_properties.value,'') as 描述 from sysobjects

    join syscolumns on sysobjects.id = syscolumns.id

    join systypes on syscolumns.xusertype = systypes.xusertype

    left join sys.identity_columns on sys.identity_columns.object_id = syscolumns.id

    and sys.identity_columns.column_id = syscolumns.colid

    left join sys.extended_properties on sys.extended_properties.major_id = syscolumns.id

    and sys.extended_properties.minor_id = syscolumns.colid

    where sysobjects.name = '表名'

  • 相关阅读:
    HDU 1082 Matrix Chain Multiplication
    HDU 1086 You can Solve a Geometry Problem too
    HDU 1099 Lottery
    jquery正则检测字符串表达式的合法性
    Like语句中的注入
    HDU 1372 Knight Moves
    HDU 1253 胜利大逃亡
    HDU 1242 Rescue
    我有新博客啦
    水平越权与垂直越权
  • 原文地址:https://www.cnblogs.com/KimhillZhang/p/1758777.html
Copyright © 2020-2023  润新知