Create Own Column Property in SQL
i want to create my one own property for every column.
ex. every column has description property but i require one more property for me.
i want required for auto code generate from that property.
what is best way开发者_如何学C for that?
Using Extended Properties on Database Objects
To add a new extended property to the SafetyStockLevel
of the dbo.Product
table use the following command:
EXEC sys.sp_addextendedproperty
@name = N'MS_DescriptionExample',
@value = N'Minimum inventory quantity.',
@level0type = N'SCHEMA', @level0name = dbo,
@level1type = N'TABLE', @level1name = Product,
@level2type = N'COLUMN', @level2name = SafetyStockLevel;
In the Object Explorer, right click the column in question and click properties.
This should open the Column Properties Window.
Select Extended Properties, and here you can add your data.
Extended properties are exactly what you're looking for. They can be specified for any database object (including columns) and retrieved using system functions/procedures.
精彩评论