MSSQL/SqlServer获取字段名与类型



1、方法一

SELECT * FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='表名' 
2、方法二

select a.name tablename, b.name colName, c.name colType ,c.length colLength

from sysobjects a inner join syscolumns b
on a.id=b.id and a.xtype='U'
inner join systypes c
on b.xtype=c.xusertype
where a.name='表名'
posted @ 2022-02-07 22:45  看不见的R  阅读(480)  评论(0编辑  收藏  举报