SQL Server obtains, adds, modifies, and deletes field descriptions.

Source: Internet
Author: User

Obtains, adds, modifies, and deletes sqlserver field descriptions.

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') AND (c. name = 'vince ') AND (o. name = 'IP _ address ')

OrDER BY o. name

Description of the province field in the ip_address table

-- Create a table and its description

Create table (a1 varchar (10), a2 char (2 ))

-- Add description information for the table

EXECUTE sp_addextendedproperty N 'Ms _ description', 'personnel info table ', N 'user', N 'dbo', N 'table', N 'table', NULL, NULL

-- Add description information for field a1

EXECUTE sp_addextendedproperty N 'Ms _ description', 'name', N 'user', N 'dbo', N 'table', N 'table', N 'column ', N 'a1'

EXECUTE sp_addextendedproperty N 'Ms _ description', 'test', N 'user', N 'dbo', N 'table', N 'hr _ Employees ', N 'column ', N 'test'

-- Add description information for field a2

EXECUTE sp_addextendedproperty N 'Ms _ description', 'gender', N 'user', N 'dbo', N 'table', N 'table', N 'column ', N 'a2'

-- Update the description attribute of column a1 in the table:

EXEC sp_updateextendedproperty 'Ms _ description', 'field 1', 'user', dbo, 'table', 'table', 'column', a1

-- Delete the description attribute of column a1 in the table:

EXEC sp_dropextendedproperty 'Ms _ description', 'user', dbo, 'table', 'table', 'column', a1

-- Delete test

Drop table

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.