zoukankan      html  css  js  c++  java
  • 使用SQL语句获取SQL Server数据库表中某字段的信息(字段名、字段说明、默认值等)

    select 
    object_name(c.id) as 表名
     ,c.name as 字段名
     ,t.name as 数据类型
     ,c.prec as 长度
     ,p.value as 字段说明
     ,m.text as 默认值
    from syscolumns c
     inner join
     systypes t
     on c.xusertype=t.xusertype
     left join 
     sys.extended_properties p
     on c.id=p.major_id and c.colid = p.minor_id
     left join
     syscomments m
     on c.cdefault=m.id
    where objectproperty(c.id,'IsUserTable')=1
     and object_name(c.id) = 'Article' and c.name = 'Hits' --本行中的"Article"为表名,"Hits"为字段名
    

      在SQL Server 2008中测试通过,运行截图:

  • 相关阅读:
    053-49
    053-3
    053-204
    053-491
    053-205
    053-57
    053-149
    053-47
    053-150
    回答2
  • 原文地址:https://www.cnblogs.com/rabtor/p/2595041.html
Copyright © 2011-2022 走看看