Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Script table as - ALTER TO is greyed out - SQL SERVER

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

like image 482
user1254579 Avatar asked Apr 30 '14 09:04

user1254579


People also ask

How do I enable alter tables in SQL?

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.

How can I create table script in SQL Server?

SELECT @SQL = 'CREATE TABLE ' + @object_name + CHAR(13) + '(' + CHAR(13) + STUFF(( SELECT CHAR(13) + ' , [' + c.name + '] ' +

How do I alter a table in SQL Server?

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.

When to use an ALTER TABLE script in SQL 2005?

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.

How do I create a change script for a table?

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).

Is it possible to generate a script from a script table?

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.


1 Answers

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.

like image 145
dean Avatar answered Oct 11 '22 12:10

dean