sql2005 获取表字段信息和视图字段信息
获取表字段名,和字段说明
SELECT
[Table Name] = OBJECT_NAME(c.object_id),
[ColumnName] = c.name,
[Description] = ex.value
FROM
sys.columns c
LEFT OUTER JOIN
sys.extended_properties ex
ON
ex.major_id = c.object_id
AND ex.minor_id = c.column_id
AND ex.name = 'MS_Description'
WHERE
OBJECTPROPERTY(c.object_id, 'IsMsShipped')=0
AND OBJECT_NAME(c.object_id) ='tablename '"
[Table Name] = OBJECT_NAME(c.object_id),
[ColumnName] = c.name,
[Description] = ex.value
FROM
sys.columns c
LEFT OUTER JOIN
sys.extended_properties ex
ON
ex.major_id = c.object_id
AND ex.minor_id = c.column_id
AND ex.name = 'MS_Description'
WHERE
OBJECTPROPERTY(c.object_id, 'IsMsShipped')=0
AND OBJECT_NAME(c.object_id) ='tablename '"
获取视图字段
select * from sys.views v inner join
sys.columns c on v.object_id=c.object_id
where v.name='vw_Employee'
sys.columns c on v.object_id=c.object_id
where v.name='vw_Employee'