SQL Server extended attributes

Source: Internet
Author: User
For more information about SqlServer extension attributes, see

For more information about SqlServer extension attributes, see

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:
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 ',
The 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:
The Code is as follows:
EXEC sp_dropextendedproperty N 'Ms _ description', N 'user', dbo, N 'table', N 'table name ',

N 'column ', field name

Modify:
The 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 ():
The Code is as follows:
-- 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:
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

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.