sql server 查询表的字段名 数据类型 和字段长度

学习记录,以备忘: 

SELECT syscolumns.name AS 字段名,systypes.name AS 数据类型,syscolumns.length AS 长度 
 FROM syscolumns INNER JOIN systypes ON systypes.xtype=syscolumns.xtype
 WHERE id=(SELECT id FROM sysobjects WHERE  name='表名')