SQLServer中查出一个表的结构

use 需要查找表所在的数据库
     [color=darkblue]select '字段名' = tsc.name, '字段类型'=tst.name,'长度'=convert(char(4),tst.length) from syscolumns tsc, systypes tst ,sysobjects sob where tsc.xtype=tst.xtype and tsc.id=sob.id and sob.id = object_id('TableName') order by colid[/color]

order by colid 字段按照表结构的顺序
TableName 需要查找表的名称

你可能感兴趣的:(数据库)