SQL Server Management Studio - how to change a field type without dropping table

In SQL Server Management Studio, when changing an existing field in design view from DECIMAL (16,14) to DECIMAL (18,14) it will not allow me to save without dropping the whole table and all its data.

Is it possible to change a field type once a database is populated with records?


Just use T-SQL script instead of the visual designer to achieve your goal:

ALTER TABLE dbo.YourTableNameHere
ALTER COLUMN YourColumnNameHere DECIMAL(18, 14) 

and you should be fine.

The visual designer takes the extra careful route of creating the table with the new structure and then copying over all the data - it works, but it's tedious. Normally, as long as you don't truncate a column (make it shorter), you can definitely change the column's datatype "in place" using a T-SQL statement.

Also: by default the SSMS designer is extra careful and won't allow any changes that require a drop-and-recreate table cycle. You can disable this extra carefullness in Tools > Options and then in this dialog box:

If you uncheck that option, you will be able to do "destructive" changes in your visual designer

Designer will still drop the table even if the option is unchecked in SSMS. It will just not prompt you next time it does it. To prove, launch the SQL profiler and alter a column using the SSMS designer and you will see a drop table command issued before the Alter table command is executed.

Need Your Help

Setting line-height on a jsTree?

css jstree

I'm using jstree to create a multi-level tree, and I want to be able to set a larger line-height than you usually see, so that I can have some large headings. (If I set the font larger, the lines ...