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 badges332 silver badges499 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 badges173 silver badges234 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,4694 gold badges61 silver badges73 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,1102 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,1831 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.5k20 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,4694 gold badges61 silver badges73 bronze badges

answered Aug 27, 2016 at 5:44

Pedram's user avatar

PedramPedram

6,21610 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,3029 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,6491 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

1891 gold badge2 silver badges10 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

Всем привет! Сегодня я расскажу об ошибке «Сохранение изменений запрещено», которая возникает в среде 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 для начинающих.

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

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 203

Backtrace:

File: /home2/d1217r24/codexqa.com/application/views/question.php
Line: 203
Function: _error_handler

File: /home2/d1217r24/codexqa.com/application/controllers/Questions.php
Line: 466
Function: view

File: /home2/d1217r24/codexqa.com/index.php
Line: 317
Function: require_once

Problem

Some Confluence troubleshooting steps require you to make changes to a SQL Server database. Depending on your SQL Server configuration, you may get the following error when making structure/schema changes: 

Saving changes is not permitted. The changes that you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created.

Cause

This warning that prevents the actions from completing is caused by the Prevent saving changes that require table re-creation option being triggered in SQL Server. This option lets SQL Server to prevent structure changes when a table needs to be recreated and is intended as a security feature. However, this also prevents planned changes from completing. 

Resolution

The resolution is to uncheck the Prevent saving changes that require table re-creation option:

As with all recommendations made by Atlassian Support, please follow best practices for Change Management and test and validate these settings in a Test/Development and Staging environment prior to rolling any changes into a Production environment. This is to validate these changes and ensure that they will function will within your infrastructure prior to placing these changes in production.

  1. Open SQL Management Studio as an administrator
  2. Go to Tools, then options then «Designer»
  3. Uncheck the Prevent saving changes that require table re-creation
  4. Expand the database tables on the left object explorer of SQL Server and make the changes you plan to make
  5. You may want to re-check the Prevent saving changes that require table re-creation in order to for the security feature to warn again

Last modified on Mar 30, 2016

Related content

  • No related content found

Понравилась статья? Поделить с друзьями:
  • Savefrom net ошибка error indexeddb api missing
  • Sc controlservice ошибка 1052
  • Savefrom net ошибка 500
  • Sc 819 ricoh ошибка
  • Sauter ek600 ошибки