SQLServer中获取特定表的所有列名

1.获取特定表的所有列名:

Select Name FROM SysColumns Where id=Object_Id('tableName')

参考:http://blog.csdn.net/wuxiaokaixinguo/article/details/8293039

 

2.获取特定表的所有列名和备注信息

SELECT
  a.column_id AS No,
  a.name AS 列名,
  isnull(g.[value],'-') AS 说明
FROM
  sys.columns a left join sys.extended_properties g
 on (a.object_id = g.major_id AND g.minor_id = a.column_id)
WHERE
  object_id =
    (SELECT object_id FROM sys.tables WHERE name = 'tableName')

 

posted @ 2016-04-13 15:29  talentzemin  阅读(2384)  评论(0编辑  收藏  举报