CREATE PROC [dbo].[sp_help_table] @tableName NVARCHAR(50)--表名称 AS BEGIN SELECT a.colorder 字段序号,a.name 字段名,b.name 字段类型,b.length AS 字段长度,g.[value] AS 字段说明 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 sys.extended_properties g on a.id=g.major_id AND a.colid = g.minor_id WHERE d.[name] =@tableName order by a.id,a.colorder END
这样,在查询某个表的时候,直接执行这个存过,参数就是表名称,最后的结果就是这样,字段说明是在新建表的时候填写的说明,如果没写这列就是NULL