sql server 新增、查詢 欄位、表註釋
環境:xp sp3,sql server2008
1、sqlserver用語句給表註釋
EXECUTE sp_addextendedproperty N'MS_Description', N'表註釋', N'user', N'dbo', N'table', N'表名', NULL,
NULL
2、sqlserver用語句給表的“欄位”註釋
EXECUTE sp_addextendedproperty N'MS_Description', N'欄位註釋', N'user', N'dbo', N'table', N'表名', N'column', N'欄位名'
3、檢視sqlserver註釋
SELECT
A.name AS table_name,
B.name AS column_name,
C.value AS column_description
FROM sys.tables A
INNER JOIN sys.columns B ON B.object_id = A.object_id
LEFT JOIN sys.extended_properties C ON C.major_id = B.object_id AND C.minor_id = B.column_id
WHERE A.name = '表名
4、順便加上sql server2000檢視註釋的語句
select so.name as table_name, sc.name as column_name, sc.xtype as data_type ,sp.value as remarks from
sysobjects so left outer join syscolumns sc on so.id = sc.id left outer join sysproperties sp on sc.id = sp.id and sc.colid = sp.smallid where so.type = 'u' and so.name='
上面的新增表和欄位註釋的語句在sql server2000 下也是可以使用的。
轉自:http://begoodluck.blog.163.com/blog/static/20450728020141191412788/