In SQL 2005, a situation may arise where you need to generate an ALTER TABLE script, for example when adding a new column to a database or changing the field type, etc.
If you want to generate a script for a particular SQL function, like CREATE, SELECT, UPDATE, etc., normally you just have to right click on the table in SQL Management Studio and choose Script Table like and then the function you want to write.
However, the option ALTER To disabled in the Table from script like menu option! So if you want to generate a script, how do you do it? Well, you can't do it this way when you edit a table.
To generate the script, first right-click on the table you want to edit and choose Design .
Now go ahead and add your new columns, change the field types, set your fields to accept NULLS or not, etc. Once you are done, you want to right click on any column or in the white space and you will see the option Generate edit script now available.
Now go ahead and save that file and you will have your ALTER TABLE script! a little confused since all other functions can be programmed simply by clicking the right mouse button, but simple once learned. To enjoy!