• Rechana Rajan - Monday, March 20, 2017 5:07 AM

    Adi Cohn-120898 - Sunday, March 19, 2017 4:16 AM

    I didn't check it for a long time, but as far as I remember the GUI creates a new table, copies the data to the new table, drops the old table and renames the new table to have the same name as the old one.  Because the GUI creates a new table and doesn't alter the existing table, you don't get an error message that you should drop any existing object that depends on the column that you try to modify.  When you are using the alter table statement,  the server alters the existing table and doesn't create a new one.  This is of course a much better approach, but  sometimes you'll might get an error message.  In your case you need to drop the index that is based on this column (and if you also have constraint that is based on it, you'll need to drop it too), modify the column and then recreate  the index and any other object that you dropped.

    Adi

    Thanks Adi. Why NO with SSMS?

    As Adi has explained, the SSMS/GUI drops and recreates the table with relevant indexes and constraints.
    You can check the script generated under "Table Designer -> Generate Change Script"


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/