This example is a statement that exports comments from a table: (the table name is bbs_bank_log)
Select sysobjects.name as the table name and syscolumns.name as the column name.
System type. Nameas the data type, syscolumns.length as the data length, and CONVERT(char,
Sysproperties。 [value]) as a comment
Join from sysproperties right outside
Sysobjects inner join
Sysobjects.id = syscolumns.id syscolumns on the inner join.
systypes ON sys columns . xtype = systypes . xtype ON
Sysproperties.id = syscolumns.id and
sys properties . smallid = sys columns . colid
Where (sysobjects.xtype = 'u' or
Sysobjects.xtype = 'v') and (systypes.name < > sysname').
-and CONVERT(char, sysproperties. [value]) < & gt' Null'-export records whose comments are not Null.
-and (sysobjects. Name =' BBS _ bank _ log ')- Associate the table names one by one, and you can use the or join condition.
Sort by table name
Precautions:
The above statement is to export all comments of a table. If you need to simply list all the comments of the table, the statement is as follows:
Select CONVERT(char, [value]) AS Expr 1
Sysobjects is the system object table, syscolumns is the system field information table, and systypes is the system type table. Annotation information can be read by associating the ID of the field with sysproperties (System Annotation Property Sheet).
View and export the annotation information of fields in the data table above SQL Server 2005:
Select minor _ id, value from sys.extended _ properties where major _ id = id order by minor _ id of data table in database.