首先,要明確一點的是註釋存在sysproperties表中而不是跟建立的表捆綁到一起的
具體使如方法如下:
一、使用SQL Server視窗建立表是會有註釋視窗;
二、使用SQL語句的comment語句,該語句放置在create table()後面,如:
comment on table table_name is "table_mark"
comment on column table_name."Column" is "column_mark"
三、呼叫系統儲存過程sp_addextendedproperty來添加註釋,如:
EXECUTE sp_addextendedproperty N"MS_Description",N"僱員資訊",N"user",N"dbo",N"table",N"Employee",NULL,NULL
EXECUTE sp_addextendedproperty N"MS_Description",N"主鍵ID,自動增加",N"user",N"dbo",N"table",N"Employee",N"column",N"EmployeeID"
或者
EXEC sys.sp_addextendedproperty @name=N"MS_Description", @value=N"角色ID" , @level0type=N"SCHEMA",@level0name=N"dbo", @level1type=N"TABLE",@level1name=N"CharData", @level2type=N"COLUMN",@level2name=N"charid"
GO
首先,要明確一點的是註釋存在sysproperties表中而不是跟建立的表捆綁到一起的
具體使如方法如下:
一、使用SQL Server視窗建立表是會有註釋視窗;
二、使用SQL語句的comment語句,該語句放置在create table()後面,如:
comment on table table_name is "table_mark"
comment on column table_name."Column" is "column_mark"
三、呼叫系統儲存過程sp_addextendedproperty來添加註釋,如:
EXECUTE sp_addextendedproperty N"MS_Description",N"僱員資訊",N"user",N"dbo",N"table",N"Employee",NULL,NULL
EXECUTE sp_addextendedproperty N"MS_Description",N"主鍵ID,自動增加",N"user",N"dbo",N"table",N"Employee",N"column",N"EmployeeID"
或者
EXEC sys.sp_addextendedproperty @name=N"MS_Description", @value=N"角色ID" , @level0type=N"SCHEMA",@level0name=N"dbo", @level1type=N"TABLE",@level1name=N"CharData", @level2type=N"COLUMN",@level2name=N"charid"
GO