使用SSMS時,經常遇到的問題是,修改一張table時,彈出一個錯誤對話框:“Saving changes is not permitted”。
這個錯誤通常是因爲以下錯誤(參閱MSDN的KB文檔 https://support.microsoft.com/en-us/kb/956176)
- You change the Allow Nulls setting for a column. 修改了一個Column是否Allow Null的屬性
- You reorder columns in the table. 對Table的Column進行了重新排序
- You change the column data type. 修改了Column的Data Type
- You add a new column. 新增了一個Column
爲了解決這個問題,有兩個方法:
- 使用UPDATE Statement
這是推薦的方式。使用SQL語句來直接執行修改。譬如,修改Allow Null屬性:
alter table MyTable alter column MyDate7 datetime NULL - 關閉SSMS選項中的“Prevent saving changes that require table re-creation”
這是不推薦的做法。具體的菜單路徑爲:Tools > Options,在對話框左側選擇 Designer,右側有“Prevent saving change that require table re-creation”的Checkbox
因爲它帶來的風險是,實際上Table被Drop瞭然後re-create了,原來的Change Trace全部丟失了。
是爲之記。
Alva Chien
2016.6.2