Make changes to SQL Server table structure by sentence

1, adding columns

  ALTER TABLE users ADD address varchar(30);

2, delete columns

  ALTER TABLE users DROP COLUMN address;

3, modify the field type

  ALTER TABLE users ALTER COLUMN address varchar(80);

4, rename columns:

  EXEC sp_rename 'WN_CALL_INFO.[CUST_CODE]', 'CUST_ID', 'COLUMN';

5, rename the table:

  EXEC sp_rename 'customers', 'custs';

When you modify the table structure, sql server will pop up a dialog box that displays the following:

You are not allowed to save your changes. Your changes required to delete and re-create the following table. You make changes or enable the "Block saving asked to re-create the table of change" option on the table can not be re-created.

Solution: menu bar -> Tools -> Options -> Designer -> Table Designer and Database Designer, right panel, uncheck the "Block saving asked to re-create changes to the table."

Guess you like

Origin www.cnblogs.com/ZaraNet/p/11646134.html