How to add a field description and obtain the field description

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.