syscolumns表结构

列名数据类型描述
namesysname列名或过程参数的名称。
idint该列所属的表对象 ID,或与该参数关联的存储过程 ID。
xtypetinyintsystypes 中的物理存储类型。
xprectinyint仅限内部使用。
xscaletinyint仅限内部使用。
colidsmallint列或参数 ID。
xoffsetsmallint仅限内部使用。
bitpostinyint仅限内部使用。
reservedtinyint仅限内部使用。
colstatsmallint仅限内部使用。
cdefaultint该列的默认值 ID。
domainint该列的规则或 CHECK 约束 ID。
numbersmallint过程分组时(0 表示非过程项)的子过程号。
colordersmallint仅限内部使用。
autovalvarbinary(255)仅限内部使用。
offsetsmallint该列所在行的偏移量;如果为负,表示可变长度行。
statustinyint

用于描述列或参数属性的位图:

0x08 = 列允许空值。
0x10 = 当添加 varchar 或 varbinary列时,ANSI 填充生效。保留 varchar 列的尾随空格,保留 varbinary 列的尾随零。
0x40 = 参数为 OUTPUT 参数。
0x80 = 列为标识列

typetinyintsystypes 中的物理存储类型。
usertypesmallintsystypes 中的用户定义数据类型 ID。
printfmtvarchar(255)仅限内部使用。
precsmallint该列的精度级别。
scaleint该列的小数位数。
iscomputedint表示是否已计算该列的标志:

0 = 未计算。
1 = 已计算。

isoutparamint表示该过程参数是否是输出参数:

1 = 真。
0 = 假。

isnullableint表示该列是否允许空值:

1 = 真。
0 = 假。

 

select 
       a.name column_name,
       (case when COLUMNPROPERTY( a.id,a.name,'IsIdentity')=1 then 1 else 0 end) column_Identity,--标识
       (case when (select count(*)
       from sysobjects
       where (name in
                 (select name
                from sysindexes
                where (id = a.id) and (indid in
                          (select indid
                         from sysindexkeys
                         where (id = a.id) and (colid in
                                   (select colid
                                  from syscolumns
                                  where (id = a.id) and (name = a.name))))))) and
              (xtype = 'PK'))>0 then 1 else 0 end) column_pk,--主键,
       b.name column_type,--类型,
       a.length column_bitlength,--占用字节数,
       COLUMNPROPERTY(a.id,a.name,'PRECISION') as column_length,--长度,
       isnull(COLUMNPROPERTY(a.id,a.name,'Scale'),0) as column_dec,--小数位数,
       (case when a.isnullable=1 then 1 else 0 end) column_isnull,--允许空,
       isnull(e.text,'') column_def,--默认值,
       isnull(g.[value],'') as column_properties --字段说明    
from  syscolumns  a left join systypes b 
on  a.xtype=b.xusertype
inner join sysobjects d 
on a.id=d.id  and  d.xtype='U' and  d.name<>'dtproperties'
left join syscomments e
on a.cdefault=e.id
left join sys.extended_properties g
on a.id=g.major_id and a.colid = g.minor_id  
WHERE
    OBJECT_NAME( A.ID ) = N'CGQSJB'
order by a.id,a.colorder

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值