Saving changes is not permitted sql server ошибка

When I create a table in SQL Server and save it, if I try to edit the table design, like change a column type from int to real, I get this error:

Saving changes is not permitted. The change you have made requires the following table to be dropped and re-created. You have either made changes to a table that can’t be recreated or enabled the option prevent saving changes that require the table to be re-created.

Why do I have to re-create the table? I just want to change a data type from smallint to real.

The table is empty, and I didn’t use it until now.

Brian Tompsett - 汤莱恩's user avatar

asked Jul 24, 2011 at 23:22

Arash's user avatar

1

From Save (Not Permitted) Dialog Box on MSDN :

The Save (Not Permitted) dialog box warns you that saving changes is
not permitted because the changes you have made require the listed
tables to be dropped and re-created.

The following actions might require a table to be re-created:

  • Adding a new column to the middle of the table
  • Dropping a column
  • Changing column nullability
  • Changing the order of the columns
  • Changing the data type of a column <<<<

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.

See Also
Colt Kwong Blog Entry:
Saving changes is not permitted in SQL 2008 Management Studio

Community's user avatar

answered Jul 24, 2011 at 23:26

Robert Harvey's user avatar

Robert HarveyRobert Harvey

178k47 gold badges333 silver badges501 bronze badges

14

If you are using SSMS:

Go to the menu Tools >> Options >> Designers and uncheck Prevent Saving changes that require table re-creation

Mohammadreza Khedri's user avatar

answered Jul 24, 2011 at 23:27

ypercubeᵀᴹ's user avatar

ypercubeᵀᴹypercubeᵀᴹ

113k19 gold badges174 silver badges235 bronze badges

5

Prevent saving changes that require table re-creation

Five swift clicks

Prevent saving changes that require table re-creation in five clicks

  1. Tools
  2. Options
  3. Designers
  4. Prevent saving changes that require table re-creation
  5. OK.

After saving, repeat the proceudure to re-tick the box. This safe-guards against accidental data loss.

Further explanation

  • By default SQL Server Management Studio prevents the dropping of tables, because when a table is dropped its data contents are lost.*

  • When altering a column’s datatype in the table Design view, when saving the changes the database drops the table internally and then re-creates a new one.

*Your specific circumstances will not pose a consequence since your table is empty. I provide this explanation entirely to improve your understanding of the procedure.

answered Jul 1, 2015 at 10:42

WonderWorker's user avatar

WonderWorkerWonderWorker

8,5394 gold badges63 silver badges74 bronze badges

2

This can be changed easily in Microsoft SQL Server.

  1. Open Microsoft SQL Server Management Studio 2008
  2. Click Tools menu
  3. Click Options
  4. Select Designers
  5. Uncheck «Prevent saving changes that require table re-creation»
  6. Click OK

enter image description here

answered Nov 5, 2018 at 14:05

Irshad Ahmed Akhonzada's user avatar

0

To change the Prevent saving changes that require the table re-creation option, follow these steps:

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.

Note: If you disable this option, you are not warned when you save the table that the changes that you made have changed the metadata structure of the table. In this case, data loss may occur when you save the table.

enter image description here

Martijn Pieters's user avatar

answered Jan 18, 2016 at 10:15

Tabish Usman's user avatar

Tabish UsmanTabish Usman

3,1202 gold badges17 silver badges15 bronze badges

1

It is very easy and simple setting problem that can be fixed in 5 seconds by following these steps

To allow you to save changes after you alter table, Please follow these steps for your sql setting:

  1. Open Microsoft SQL Server Management Studio 2008
  2. Click Tools menu options, then click Options
  3. Select Designers
  4. Uncheck «prevent saving changes that require table re-creation» option
  5. Click OK
  6. Try to alter your table
  7. Your changes will performed as desired

answered Jan 22, 2014 at 11:03

Rizwan Gill's user avatar

Rizwan GillRizwan Gill

2,2031 gold badge17 silver badges29 bronze badges

1

Go on Tool located at top menu.
Choose options from dropdown.You have a popup now select Designers option located on left hand block of menus. Uncheck the option Prevent saving changes that require table re-creation. Click on OK Button.

Andrew Barber's user avatar

Andrew Barber

39.7k20 gold badges94 silver badges123 bronze badges

answered Apr 14, 2013 at 15:39

FIFO BIZSOL's user avatar

FIFO BIZSOLFIFO BIZSOL

7296 silver badges6 bronze badges

Un-tick the Prevent saving changes that require table re-creation box from Tools ► Options ► Designers tab.

SQL Server 2012 example:

enter image description here

WonderWorker's user avatar

WonderWorker

8,5394 gold badges63 silver badges74 bronze badges

answered Aug 27, 2016 at 5:44

Pedram's user avatar

PedramPedram

6,28410 gold badges65 silver badges87 bronze badges

Copied from this link
» … Important We strongly recommend that you do not work around this problem by turning off the Prevent saving changes that require table re-creation option. For more information about the risks of turning off this option, see the «More information» section. »

» …To work around this problem, use Transact-SQL statements to make the changes to the metadata structure of a table. For additional information refer to the following topic in SQL Server Books Online

For example, to change MyDate column of type datetime in at table called MyTable to accept NULL values you can use:

alter table MyTable alter column MyDate7 datetime NULL «

Panther's user avatar

Panther

3,3129 gold badges27 silver badges50 bronze badges

answered Sep 30, 2015 at 5:25

Panagiotis's user avatar

PanagiotisPanagiotis

1311 silver badge2 bronze badges

4

And just in case someone here is also not paying attention (like me):

For Microsoft SQL Server 2012, in the options dialogue box, there is a sneaky little check box that APPARENTLY hides all other setting. Although I got to say that I have missed that little monster all this time!!!

After that, you may proceed with the steps, designer, uncheck prevent saving blah blah blah…

sneaky_check_box_in_option

answered Mar 21, 2016 at 7:47

Gellie Ann's user avatar

Gellie AnnGellie Ann

4391 gold badge6 silver badges10 bronze badges

1) Open tool which is on top.
2) Choose options from Picklist.
3) Now Comes the popup and you can now select designers option from the list of menus on the left side.
4) Now prevent saving changes need to be unchecked that needed table re-creation. Now Click OK.

answered Dec 18, 2015 at 10:54

Rishabh Seth's user avatar

From the Tools menu, click on Options, select Designers from the side menu and untick prevent changes that can lead to recreation of a table. Then save the changes

If you use sql server Management studio go to
Tools >> Options >> Designers and uncheck “Prevent Saving changes that require table re-creation”
It works with me

answered Aug 9, 2018 at 11:24

Taher Chtaywi's user avatar

1

If you can not see the «Prevent saving changes that required table re-creation» in list like that
The image

You need to enable change tracking.

  • Right click on your database and click Properties
  • Click change tracking and make it enable
  • Go Tools -> Options -> Designer again and uncheck it.

answered May 14, 2018 at 15:51

Emre Karataşoğlu's user avatar

Emre KarataşoğluEmre Karataşoğlu

1,6591 gold badge16 silver badges25 bronze badges

Actually, You are blocked by SSMS not the SQL Server.

The solution are either change setting of SSMS or use a SQL query.

Using SQL Query you could do the update freely.
Example you want to add a new column to a table, you could do like this :

ALTER TABLE Customers ADD Email varchar(255) NOT NULL DEFAULT ‘OK’;

Other option is changing SSMS setting. Please refer to other answer, as many has explain it.

answered Sep 8, 2020 at 15:07

Ahmad Pujianto's user avatar

Ahmad PujiantoAhmad Pujianto

3091 gold badge3 silver badges11 bronze badges

2

When you install the Microsoft SQL Server Management Studio, the default settings do not allow you to save any changes to the structure of your tables that would cause the tables to be dropped and recreated and creating an error commonly known as SQL server error, which can be extremely limiting when you are needing to make a quick change using the interface.

SQL Server Error Solution

The good news is that it is very easy to change this setting by following these steps:

  1. Open SQL Server Management Studio
  2. From the file menu, choose Tools à Options
  3. From the left menu, choose Designers
  4. Uncheck the box entitled Prevent saving changes that require table re-creation
  5. Press OK to save

SQL Server Error

That’s it!

More SQL content:

  1. Float vs Decimal in SQL
  2. Cannot resolve the collation conflict
  3. Calculate the most recent Monday in SQL

You might have faced an error as shown below, when you make some changes in table from design mode in SQL server management studio (SSMS).

‘Saving changes is not permitted. The change you have made requires the following table to be dropped and re-created. You have either made changes to a table that can’t be recreated or enabled the option prevent saving changes that require the table to be re-created.’

It usually happens when you make any change that require the table to be dropped and re-created such as changing the column data type, Adding a column between two existing columns, changing the column nullability, or deleting a column from design mode in SSMS.

Lets see the case when an error occurs, and try to resolve that.

Suppose you have a EmployeeData table and you need to change the column data type size for EmpName column.

Lets do this using design mode in SQL server management studio (SSMS).

To open the table in design mode, just right click on table, and click on Design.

Once you click on Design, you will see a table is opened in edited mode as shown below.

Lets change the data type size of column EmpName from varchar(50) to varchar(100).

After making changes in data type size, when you try save the change by pressing Ctrl +S.

You  will get an error message as shown below.

Click on Cancel button to close error message dialog box.

You can resolve this error by changing the default table setting for editing a table from design mode.

Lets go step by step and change the setting for editing a table.

In SQL Server Management Studio (SSMS), Go to Tools then click on Option..

After that a Options dialog box opens,  now expand the Designers, and select Tables and Database Designers. 

Now on the right side, you will see a table options there uncheck the box Prevent saving changes that require table re-creation.

Also Note that: By unchecking this option, when you change a table basically you alter the metadata structure of the table, and then save the table, the table must be re-created based on these changes. This may result in the loss of metadata and in a direct loss of data during the re-creation of the table. So it is recommended that to use T-SQL alter table command for modifying a table definition such as altering, adding, or dropping columns and constraints.  

After that click OK to save the settings.

After making changes in setting, Lets try to change the data type size again.

You can see, this time it does not return any error and changes in table are saved.

Also Read..

Get Dark theme in SQL Server Management studio

Get the detailed information of all datatypes in SQL Server

SQL Basics Tutorial SQL Advance Tutorial SSRS Interview Q & A
SQL Create table SQL Server Stored Procedure Create a New SSRS Project List Of SQL Server basics to Advance Level Interview Q & A
SQL ALTER TABLE SQL Server Merge Create a Shared Data Source in SSRS SQL Server Question & Answer Quiz
SQL Drop SQL Server Pivot Create a SSRS Tabular Report / Detail Report
….. More …. More ….More
Power BI Tutorial Azure Tutorial Python Tutorial SQL Server Tips & Tricks
Download and Install Power BI Desktop Create an Azure storage account Learn Python & ML Step by step Enable Dark theme in SQL Server Management studio
Connect Power BI to SQL Server Upload files to Azure storage container SQL Server Template Explorer
Create Report ToolTip Pages in Power BI Create Azure SQL Database Server Displaying line numbers in Query Editor Window
….More ….More ….More

Loading

Всем привет! Сегодня я расскажу об ошибке «Сохранение изменений запрещено», которая возникает в среде SQL Server Management Studio при работе с конструктором таблиц, будут рассмотрены причины ее возникновения и, конечно же, способы исправления данной ошибки.

Ошибка «Сохранение изменений запрещено» в среде SSMS. Причины и способы устранения

Заметка! Обзор функционала SQL Server Management Studio (SSMS).

Содержание

  1. Ошибка «Сохранение изменений запрещено»
  2. Причины возникновения ошибки «Сохранение изменений запрещено»
  3. Способы устранения ошибки «Сохранение изменений запрещено»
  4. Использовать T-SQL
  5. Отключить параметр «Запретить сохранение изменений, требующих повторного создания таблицы»

Ошибка «Сохранение изменений запрещено»

Итак, ситуация: Вы вносите изменения в таблицу с помощью конструктора в среде SQL Server Management Studio, однако при попытке сохранить изменения Вы получаете следующую ошибку

Сохранение изменений запрещено. Чтобы сохранить изменения, необходимо удалить и повторно создать следующие таблицы. Либо изменения вносятся в таблицу, которую невозможно создать повторно, либо включен параметр «Запретить сохранение изменений, требующих повторного создания таблицы».

Скриншот 1

Причины возникновения ошибки «Сохранение изменений запрещено»

Дело в том, что при изменении таблицы с помощью конструктора с изменением структуры ее метаданных, чтобы сохранить все изменения, необходимо пересоздать таблицу на основе этих изменений, т.е. создать ее заново. Вы этого не видите, но это будет делать сама среда Management Studio.

Однако это действие может привести к потере метаданных и прямой потере данных во время повторного создания таблицы.

Поэтому по умолчанию в среде SQL Server Management Studio включен параметр «Запретить сохранение изменений, требующих повторного создания таблицы». И если Вы используете графический конструктор таблиц, чтобы внести изменения в таблицу, например, Вы выполняете следующие действия:

  • Меняете параметр «Разрешить значения NULL» для столбца;
  • Изменяете порядок столбцов в таблице;
  • Изменяете тип данных столбца;
  • Добавляете новый столбец.

то в этих случаях Вы будете получать именно такую ошибку.

Способы устранения ошибки «Сохранение изменений запрещено»

Вы можете спросить, «а как же тогда вносить изменения в таблицы, если существует прямой запрет на внесения изменений?».

Конечно же, существуют способы устранения данной ошибки и внесение изменений в таблицы. В частности, Вы можете использовать два.

Использовать T-SQL

Первый, и рекомендованный – это использовать инструкции T-SQL.

Заметка! Что такое T-SQL. Подробное описание для начинающих.

В качестве примера давайте представим, что у нас есть таблица Goods, и она имеет следующие данные.

   
   CREATE TABLE Goods(
	  ProductId INT IDENTITY(1,1) NOT NULL,
	  Category INT NOT NULL,
	  ProductName VARCHAR(100) NOT NULL,
	  Price MONEY NULL
   );

   INSERT INTO Goods (Category, ProductName, Price)
	    VALUES (1, 'Системный блок', 50),
		   (1, 'Клавиатура', 30),
		   (1, 'Монитор', 100),
		   (2, 'Планшет', 150),
		   (2, 'Смартфон', 100);

   SELECT * FROM Goods;

Скриншот 2

Заметка! Если Вас интересует язык SQL, то рекомендую почитать книгу «SQL код» – это самоучитель по языку SQL для начинающих программистов. В ней очень подробно рассмотрены основные конструкции языка.

Изменяем параметр «Разрешить значения NULL»

Как видим, столбец Price на текущий момент у нас может принимать значения NULL, однако мы решили сделать этот столбец обязательным к заполнению и запретить хранение в нем значений NULL.

Курс по SQL для начинающих

Если мы будем использовать конструктор таблиц, то мы получим ошибку «Сохранение изменений запрещено».

Чтобы запретить хранение NULL значений, мы можем выполнить следующую инструкцию SQL

   
   ALTER TABLE Goods ALTER COLUMN Price MONEY NOT NULL;

Однако помните о том, что в столбце на момент выполнения инструкции уже не должно быть значений NULL, Вы их должны устранить.

Изменяем тип данных столбца

Если необходимо изменить тип данных столбца, то нужно написать практически точно такую же инструкцию, только при этом указав новый тип данных.

   
   ALTER TABLE Goods ALTER COLUMN Price NUMERIC(18,2) NOT NULL;

В данном случае мы изменили тип данных столбца Price с MONEY на NUMERIC.

Добавляем новый столбец

Если требуется добавить новый столбец, то Вы можете использовать следующую инструкцию.

   
   ALTER TABLE Goods ADD ProductDescription VARCHAR(300) NULL;

В этом примере мы добавили столбец ProductDescription с типом данных VARCHAR.

К сожалению, изменение порядка столбцов в таблице на языке T-SQL не поддерживается, это возможно только путем пересоздания таблицы.

Заметка! Транзакции в T-SQL – основы для новичков с примерами.

Отключить параметр «Запретить сохранение изменений, требующих повторного создания таблицы»

Если Вы не хотите вникать в SQL, то Вы можете просто отключить параметр «Запретить сохранение изменений, требующих повторного создания таблицы» и в таком случае Вы сможете вносить в таблицы все перечисленные выше изменения, которые ранее были недоступны, включая изменение порядка столбцов.

Однако Microsoft не рекомендует отключать этот параметр, ссылаясь на то, что при определенных обстоятельствах сохранение изменений, требующих повторного создания таблицы, может привести к потере метаданных и прямой потере данных. Например, если у таблицы включен функционал «Отслеживания изменений».

В большинстве случаев потери данных, конечно же, не будет происходить, поэтому данный параметр отключить можно, но лучше использовать SQL.

Чтобы отключить данный параметр, зайдите в SSMS в меню «Сервис -> Параметры» и на вкладке «Конструкторы» снимите галочку «Запретить сохранение изменений, требующих повторного создания таблицы» и нажмите «ОК».

Скриншот 3

После этого Вы сможете сохранять любые изменения в таблицах с помощью графического конструктора.

Заметка! Курсы по Transact-SQL для начинающих.

На сегодня это все, надеюсь, материал был Вам полезен, пока!

In this article, we will discuss the reasons behind the “Saving changes is not permitted in SQL server” error. You will know how you can solve this error. Also, you will see some examples of this situation.

  • What are the reasons?
  • How can we fix it?
  • What is the alternative?
  • The best approach to solve the issue

What are the reasons?

Generally, this error arises when you try to alter the table structure like changing the data type. In SQL Server Management Studio, there are certain actions for which it drops the table and creates it again.

The possible actions can be:

  • You are trying to reorder the columns.
  • Trying to add a new column.
  • Changing the data type of a column.
  • Change the Allow Null settings for a column.
  • Change the table filegroup or its text/image data

Dropping the table can result in data loss. Therefore, the SQL Server Management Studio prevents this action and gives us a warning. There is an option “Prevent saving changes that require the table re-creation“ that is by default enabled and shows us this error.

saving changes is not permitted
Error

However, you can disable this option in the settings. We will see how we can disable this option in SQL Server Management Studio.

How can we fix it?

You can remove this error by disabling the the Prevent saving changes that require the table re-creation option in settings. The following steps will guide you to disable this option:

  • Go to Tools menu, click Options to open the options window.
saving changes is not permitted in sql server
Options Window
  • Click on Designers options and uncheck the option Prevent saving changes that require the table re-creation to disable the option and click OK.
saving changes is not permitted sql server
Disable the Prevent saving changes that require table re-creation Option
  • Once you have disabled this option, you will no longer face this issue.
  • However, it is not a good approach and you should try the alternative method.

Read: Identity Column in SQL Server

What is the alternative?

It is not necessary that you disable the Prevent saving changes that require the table re-creation option. You can also use the ALTER TABLE statement to perform some of the operations that generate this error.

For example, you want to change the data type of a column. If you will try it without query in SQL Server Management Studio, you will face the saving changes is not permitted error.

However, if you do this with the ALTER TABLE statement, you will not face this error. Note that the data type conversion of a column should be possible.

  • Consider the following structre of a table ProductsTable.
saving changes is not permitted in sql server 2019
ProductsTable Structure
  • Let us say you want to change the data type of the ProductID column from int to nchar(20). You will write the ALTER TABLE statement as:
ALTER TABLE dbo.ProductsTable
ALTER COLUMN ProductID nchar(20)
  • Now refresh the table and check its structure again.
saving changes is not permitted sql server 2019
Data Type Changed
  • Also, if the column had integer values earlier, the SQL Server will convert these values into nchar(20) values.

In this way, you can use the ALTER TABLE statement to perform other operations also like adding or removing the NULL property.

Read: Delete Duplicate Rows in SQL Server

The best approach to solve the issue

You should always use the ALTER TABLE statement to perform the operations like changing a column’s data type, adding or removing the NULL or NOT NULL constraints etc.

You can disable the Prevent saving changes that require the table re-creation option. However, it is not recommended to do so.

Disabling this option can result in data loss. This is because when you alter the table’s meta-structure, the SQL Server Management Studio will drop the table first and create it again.

Dropping of the table can result in the loss of various information. For example, in SQL Server, there is a feature named Change Tracking. If you have enabled this option, the SQL Server tracks changes to the table. If the table is dropped, this tracking information will also be deleted.

Thus, prefer to use the ALTER STATEMENT to change the meta-structure rather than using SQL Server Managemen Studio method and disabling the Prevent saving changes that require the table re-creation option.

Otherwise, disable this option only if you are not using the Change Tracking feature.

You may like the following sql server tutorials:

  • SQL Server Convert Function
  • SQL Server Convert Datetime to date
  • Exception Handling in SQL Server
  • SQL Server convert integer to string
  • SQL Server Create Temp Table

In this sql server tutorial, we learned how to fix errors, Saving changes is not permitted in SQL Server. The reason for the error and fixes for Saving changes is not permitted in SQL Server.

Bijay

I am Bijay having more than 15 years of experience in the Software Industry. During this time, I have worked on MariaDB and used it in a lot of projects. Most of our readers are from the United States, Canada, United Kingdom, Australia, New Zealand, etc.

Want to learn MariaDB? Check out all the articles and tutorials that I wrote on MariaDB. Also, I am a Microsoft MVP.

Понравилась статья? Поделить с друзьями:
  • Saver газовое оборудование ошибки
  • Saver гбо ошибки
  • Sauter ek600 ошибка f411
  • Saunier duval ошибка f19
  • Saunier duval ошибка f11