Red Gate forums :: View topic - Add A Column To A Table With ExtendedProperty
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation

SQL Prompt code snippets forum

Add A Column To A Table With ExtendedProperty

Search in SQL Prompt code snippets forum
Post new topic   Reply to topic
Jump to:  
Author Message
aultmike



Joined: 08 Jan 2010
Posts: 26
Location: Canton, OH

PostPosted: Tue Jul 13, 2010 9:41 pm    Post subject: Add A Column To A Table With ExtendedProperty Reply with quote

I use this snippet when I want to add a column to a table and want to add a blurb about this columns purpose.

Getting into the habit of using the ExtendedProperty also allows me to use SQLDoc to create documentation. No brainer! Wink

USE <DatabaseName>

BEGIN TRANSACTION
GO
ALTER TABLE dbo.<TableName> ADD <ColumnName> <DataType> NULL
GO
--The statement below allows you to add a description to the field
--you're adding so that you can use SQLDoc to generate documentation
EXEC sp_addextendedproperty N'MS_Description',
N'<Description of the purpose of the column>',
'SCHEMA', N'dbo', 'TABLE', N'<TableName>', 'COLUMN', '<ColumnName>'
GO
COMMIT
GO
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group