Script table as - ALTER TO is greyed out - SQL SERVER 2005 and sql server 2008. Is there any way to enable this>? or do we still write the alter command to alter any table?
It seems ALTER using right click on the object is only applicable to SPs and functions
Open SQL Server Management Studio (SSMS). On the Tools menu, click Options. In the navigation pane of the Options window, click Designers. Select or clear the Prevent saving changes that require the table re-creation check box, and then click OK.
SELECT @SQL = 'CREATE TABLE ' + @object_name + CHAR(13) + '(' + CHAR(13) + STUFF(( SELECT CHAR(13) + ' , [' + c.name + '] ' +
Use the "Design" function in SQL Server Management Studio to generate the ALTER script for you: Right-click on the table you want to alter and choose Design. Add new columns, change field types, set your fields to accept NULLS or not, etc.
In SQL 2005, you may come across a situation where you need to generate a ALTER TABLE script, such as when adding a new column to a database or changing the field type, etc.
Right-click on the table you want to alter and choose Design. Add new columns, change field types, set your fields to accept NULLS or not, etc. Once you are done, click the Generate Change Script toolbar button (or right-click on any column or in the white space).
However, the ALTER To option is disabled in the Script Table as menu option! So if you want to generate a script, how do you go about doing it? Well, you can’t do it this way when you alter a table.
This command is not available for tables (but is for the other objects). The alternative is either to use "Design" from the same menu, or to write down your own change scripts. I'd definitely recommend to avoid the designer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With