SQL Server 2008:无法在中间位置插入新列并更改数据类型 [英] SQL Server 2008 : Cannot Insert new column in the middle position and change data type

查看:16
本文介绍了SQL Server 2008:无法在中间位置插入新列并更改数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的操作系统是 Windows Server 2008.

My OS is Windows server 2008.

我已经安装了 SQL Server Express 2008.

I've already installed SQL Server Express 2008.

我有几个问题:

  1. 我无法在中间位置插入新列.如果我插入最后一个,我可以保存表格设计.
  2. 我可以更改列名,但无法更改数据类型.

我收到错误消息:不允许保存更改.您所做的更改需要删除并重新创建以下表.您对无法重新创建的表进行了更改,或者启用了阻止保存需要重新创建表的更改选项.

I got error message : Saving changes is not permitted. The changes 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 recreated or enabled the option Prevent saving changes that require the table to be re-created.

示例:

我有 ID、Name、Phone、Status 列.我无法在 NamePhone 之间添加 Address.

I have ID, Name, Phone, and Status columns. I am unable to add Address between Name and Phone.

但是,如果我把它放在Status之后,我可以添加Address.

But, I can add Address if i place it after Status.

有什么办法可以解决这个问题吗?

Is there any way to solve this problem?

之前谢谢.

推荐答案

在 SSMS 工具 -> 选项 -> 设计器中,您需要取消选中防止保存需要重新创建表的更改"选项以允许您执行此操作在 SSMS 中.

In SSMS Tools -> Options -> Designers you would need to uncheck the option "Prevent Saving Changes that require table re-creation" to allow you to do this in SSMS.

这将重建表,因此如果表很大,通常不值得麻烦,并且会使部署到生产变得更加棘手.

This will rebuild the table and so generally isn't worth the hassle if the table is at all large and will make deployment to production trickier.

如果有些列在逻辑上您希望彼此相邻以使编写查询更容易,您可以创建一个具有所需列顺序的视图.

If there are columns which logically you would prefer to have next to each other to make writing queries easier you can create a View with the desired column order.

这篇关于SQL Server 2008:无法在中间位置插入新列并更改数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆