How to include column Description in 'Create Table' script

SQL Server 2005
I have populated the Description field for several columns in a table, and would like to keep them when I create a script to create the table.  How can this be done?
jkornitAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Aneesh RetnakaranDatabase AdministratorCommented:
from BOL

B. Adding an extended property to a column in a table
The following example adds a caption property to column PostalCode in table Address.

 Copy Code
USE AdventureWorks;
GO
EXEC sp_addextendedproperty
@name = N'Caption', @value = 'Postal code is a required column.',
@level0type = N'Schema', @level0name = Person,
@level1type = N'Table',  @level1name = Address,
@level2type = N'Column', @level2name = PostalCode;
GO
 
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jkornitAuthor Commented:
Excellent.  I accidentally found it just before reading your post (after I searched for about 20 minutes in SSMS Options and Help).  By going to Options | Scripting | Script Extended Properties, I finally got SSMS to script the description properties just as you showed.
Thanks.
0
Kevin CrossChief Technology OfficerCommented:
As Aneesh has shown.  If you put the description or caption in as an extended property of the column(s) in your table.  When you open SQL Management Studio and right-click on the table name and select:

Script Table as --> CREATE To --> New Query Editor Window

You will see that the generated SQL includes to the table creation as well as addition of extended property using the stored procedure shown.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.