Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update Extended Properties of a Column?

The questions really says it all, Is it possible to update an extended property of a column in a table. I have been looking around online but they only seem to show updating the extended property for a table and not the columns in a table.

like image 819
Ben Avatar asked Apr 03 '14 09:04

Ben


People also ask

What are extended properties?

Extended properties are a series of properties stored in property sets, which can be saved as part of an object in the metadata. These properties act as placeholders that allow you to store values on different objects.

How do I get extended properties in SQL Server?

Create Sample Extended Properties To enter an extended property in SSMS, right click on a database and select Properties. On the Database Properties window go to Extended Events and add a new property.

How do I drop an extended property?

Right click on Table/View in Object Explorer, select Properties. Select Extended Properties from the pane on the left. Select the extended properties and click Delete at the bottom right of the window.


1 Answers

EXECUTE sp_updateextendedproperty 
N'MS_Description', 
@v, 
N'SCHEMA', N'dbo', 
N'TABLE', N'Table_1', 
N'COLUMN', N'i'

It's actually the very first sample in MSDN topic:

http://technet.microsoft.com/en-us/library/ms186885.aspx

Here's a more complete sample:

--Add extended property
EXEC sp_addextendedproperty 
    @name = N'Question1'
    ,@value = N'Hello'
    ,@level0type = N'Schema', @level0name = dbo
    ,@level1type = N'Table',  @level1name = Acceptance
    ,@level2type = N'Column', @level2name = P101;
GO
--Verify
SELECT * FROM fn_listextendedproperty
(NULL, 'schema', 'dbo', 'table', 'Acceptance', 'column', 'P101');
GO
--Update the extended property.
EXEC sp_updateextendedproperty 
    @name = N'Question1'
    ,@value = N'Hello, What is your name'
    ,@level0type = N'Schema', @level0name = dbo
    ,@level1type = N'Table',  @level1name = Acceptance
    ,@level2type = N'Column', @level2name = P101;
GO
--Verify
SELECT * FROM fn_listextendedproperty
(NULL, 'schema', 'dbo', 'table', 'Acceptance', 'column', 'P101');
GO
like image 69
dean Avatar answered Oct 01 '22 22:10

dean