"Go" specifies a description for a column when creating a table with an SQL statement (description)

Source: Internet
Author: User

How to specify a description for a column when creating a table with an SQL statement. The sp_addextendedproperty is used primarily for this stored procedure.

Grammar

sp_addextendedproperty    [@name =] {' property_name '}    [, [@value =] {' V Alue '}         [, [@level0type =] {' Level0_object_type '}                      , [@ Level0name =] {' Level0_object_name '}                  [, [@level1type =] {' Level1_object_type '}                                       , [@level1name =] {' Level1_object_name '}   & nbsp;                      [, [@level2type =] {' Level2_object_type '}   &NBsp;                                                   , [@level2name =] {' level2_ object_name '}                          ]                  ]        ]       ]

--Create a table
Create TABLE table (A1 varchar), A2 char (2))

--Add descriptive information to the table
EXECUTE sp_addextendedproperty n ' ms_description ', ' Personnel information table ', n ' user ', n ' dbo ', n ' table ', n ' tables ', NULL, NULL

--Add descriptive information for field A1
EXECUTE sp_addextendedproperty n ' ms_description ', ' name ', n ' user ', n ' dbo ', n ' table ', n ' tables ', n ' column ', n ' A1 '

--Add descriptive information for field A2
EXECUTE sp_addextendedproperty n ' ms_description ', ' Gender ', n ' user ', n ' dbo ', n ' table ', n ' tables ', n ' column ', n ' A2 '

--Update the Description property of the column A1 in the table:
EXEC sp_updateextendedproperty ' ms_description ', ' Field 1 ', ' user ', dbo, ' table ', ' table ', ' column ', A1

--Delete The Description property of the column A1 in the table:
EXEC sp_dropextendedproperty ' ms_description ', ' user ', dbo, ' table ', ' Tables ', ' column ', A1

--Delete test
drop table

/**************************************************************************

The above in SQLServer2012 under Pro-Test available

Reprinted from: http://www.cnblogs.com/IcefishBingqing/archive/2010/09/02/1815653.html#undefined

**************************************************************************/

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.