Adding a new column to an existing table??? Check the rules first
Hi All,
So, you are standing at the gates where you need to add a new COLUMN to an existing table.
Well, there are 2 cases:
- Table is empty
- Table contains data
If “Table is empty” then you are still in design-phase of that table. Add new column whichever the way you know 🙂
E.g. Using T-SQL or through design mode of table etc.
But if “Table contains data” then you must go through the following rules before you take any action, otherwise you will simply get (guiding :)) errors.
- ALTER TABLE only allows columns to be added that can contain nulls
- ALTER TABLE only allows columns to be added that have a DEFAULT definition specified
- The column being added is an identity or timestamp column
- If none of the previous conditions are satisfied the table must be empty to allow addition of new column.
Simple & interesting! Isn’t it?
Thanks, Khilit
Nice post Khilit.
Thanks for sharing such simple & interesting tips.
Keep sharing
Nilesh
http://www.nileshgule.com
Great article, thanks for sharing.
Wow, this is really good information. Thank you sir.
Tim