sql2005 獲取表欄位資訊和檢視欄位資訊

iSQlServer發表於2009-08-07
獲取表欄位名,和欄位說明

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 '"

獲取檢視欄位

select * from sys.views  v  inner join
sys.columns c 
on  v.object_id=c.object_id 

where v.name='vw_Employee'

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/16436858/viewspace-611636/,如需轉載,請註明出處,否則將追究法律責任。

相關文章