How to add a field description and obtain the field description! New: in SQL Server 2000, Microsoft added extended attributes to help users define and operate user-defined attributes on multiple database objects. Exec sp_addextendedproperty n 'Ms _ description', N 'field description', N 'user', N 'dbo', N 'table', N 'table name ', N 'column ', N 'field name' Go
For example: Exec sp_addextendedproperty n 'Ms _ description', N 'address', N 'user', DBO, N 'table', N 'A', N 'column', a_add Go -- my table is a. Add the field description to the field a_add: address.
Others: Delete: exec sp_dropextendedproperty n 'Ms _ description', N 'user', DBO, N 'table', N 'table name', N 'column', field name Modify: exec sp_updateextendedproperty n 'Ms _ description', N 'field description', N 'user', DBO, N 'table', N 'table name', 'column ', Field As for the query, SQL Server provides the system function fn_listextendedproperty (): -- Obtain the description of a field select * From: fn_listextendedproperty (null, 'user', 'dbo', 'table', 'table name', 'column', default) -- other variables, you can write as required, as long as the table name is changed to your Where objname = 'field name'
You can also query the table by yourself: Select O. Name as tablename, C. Name as columnname, P. [value] As description From sysproperties P inner join Sysobjects o on O. ID = P. ID inner join Syscolumns C on p. ID = C. ID and P. smallid = C. colid Where (P. Name = 'Ms _ description ') Order by O. Name |