SQL Server extended attributes

Source: Internet
Author: User

The extended attributes in sqlserver help are described as follows:
The extended properties property sets or retrieves provider-specific connection information that cannot be explicitly described through the property mechanic.
You can perform the following operations on extended attributes:

CopyCode The Code is as follows: 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 ',Copy codeThe Code is as follows: n 'A', N 'column ', a_add
Go -- my table is a. Add the field description to the field a_add: address.

Others:

Delete:

Copy code The Code is as follows: exec sp_dropextendedproperty n 'Ms _ description', N 'user', DBO, N 'table', N 'table name ',

N 'column ', field name

Modify:Copy codeThe Code is as follows: 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 ():Copy codeThe Code is as follows: -- get 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: copy Code the code is as follows: 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

Related Article

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.