select left(A.name,20) col, left(C.name,20) type, A.length from syscolumns A, sysobjects B, systypes C
where A.id = B.id
and A.xtype = C.xtype
and B.name = yourtablename
order by A.colorder

解决方案 »

  1.   

    select d.name,a.name ,b.name ,a.length, a.isnullable from syscolumns a, systypes b,sysobjects d where a.xtype=b.xusertype and a.id=d.id and d.xtype='U'
      

  2.   

    下面的语句得到当前数据库所有用户表的字段属性.select object_name(c.id) as 表名
    ,c.name as 字段名
    ,t.name 数据类型
    ,c.prec as 长度
    ,p.value as 字段说明
    ,m.text as 默认值
    from syscolumns c
    inner join
    systypes t
    on c.xusertype=t.xusertype
    left join 
    sysproperties p
    on c.id=p.id and c.colid = p.smallid
    left join
    syscomments m
    on c.cdefault=m.id
    where objectproperty(c.id,'IsUserTable')=1
    --and c.name in('字段1','字段2'...)  --加上这个条件,就可以得到指定字段的属性