SQL Server - Can you add field descriptions in CREATE TABLE?

后端 未结 4 1038
春和景丽
春和景丽 2020-12-25 13:36

I can see plenty of posts about where the field description extended property lives and how I can get it, but nothing about adding these at the CREATE TABLE stage.

I

4条回答
  •  难免孤独
    2020-12-25 14:24

    SQL Server provides a system stored procedure that allows you to add descriptions, one name-value pair at a time

    Example as follows:

    EXEC sys.sp_addextendedproperty 
    @name=N'Column 2 Description' -- Give your description a name
       , @value=N'blah blah 2 for a specific column' -- Actual description
       , @level0type=N'SCHEMA'
       , @level0name=N'dbo'
       , @level1type=N'TABLE'
       , @level1name=N'MyTestTable' -- Name of your table
    GO
    

    You would have to repeat for each description name-value pair

    Hope this helps

提交回复
热议问题