Right click script alter table disabled in SQL Server Management Studio

60,818

Solution 1

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.
  • Once you are done, click the Generate Change Script toolbar button (or right-click on any column or in the white space). This button looks like a floppy disk hovering over a piece of curled paper
  • Save the result to a text file

Depending on how you have your SSMS options set, this may not be available initially if the changes require tables to be dropped and re-created. To change this option, on the Tools menu, click Options, expand Designers, and then click Table and Database Designers. Select or clear the Prevent saving changes that require the table to be re-created check box.

Solution 2

1) Right-click on the table you want to alter and choose Design

2) Add your new columns, change the field types, set your fields to accept NULLS or not, etc.

Important: Don't save your changes now

3) Do a right-click on any column or in the white space and you’ll see the option Generate Change Script is now available.

Solution 3

In SQL Server Management Studio 2016, toolbar button icon has changed. See the highlighted new icon.

New Icon for Generate Change Script

Share:
60,818
Himanshu
Author by

Himanshu

#SOreadyToHelp A passionate cricketer (by heart!). An enthusiastic programmer (by mistake!).

Updated on July 05, 2022

Comments

  • Himanshu
    Himanshu almost 2 years

    I want to script a table as Alter to a New Query Editor Window. But this option is disabled. How can I do this?

  • MC9000
    MC9000 about 4 years
    This option "Generate Change Script" is permanently greyed out in SSMS! Any ideas on how to fix this?
  • MC9000
    MC9000 about 4 years
    This option "Generate Change Script" is permanently greyed out in SSMS! Any ideas on how to fix this?
  • VladL
    VladL about 4 years
    @MC9000 it is enabled after you've done some changes, not before
  • MC9000
    MC9000 about 4 years
    no, it's something else - it's greyed out, regardless, unfortunately. I solved it by using an alter table script which i do from here on out (the GUI is too flakey)
  • KWallace
    KWallace over 2 years
    @MC9000 The "Generate Change Script" will not enable unless you actualy DO change something in the design.