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.
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.
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.
Un-tick the
Prevent saving changes that require table re-creation
box from Tools ► Options ► Designers tab.SQL Server 2012 example:
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.
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.
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...