SQL Server Express:创建数据库表后无法添加主键
场景:我创建了一个数据库表。当我尝试向表中添加主键(使用 SQL Server Management Studio)时,它失败并显示错误消息“不允许保存更改。您所做的更改需要删除并重新创建以下表”您对无法重新创建的表进行了更改,或者启用了阻止保存需要重新创建表的更改选项。”
环境是Windows 7。
我之前在Windows XP SP2上安装过它并且可以运行。
是的,我的桌子是空的(新创建的)。
我当前的解决方法是运行“删除并创建”脚本。另一种选择是在保存表之前创建主键。
这是 Express 版本的错误还是限制?
Scenario: I have created a database table. And when I tried to add a primary key (using the SQL Server Management Studiio) to the table, it failed with an error message "Saving changes is not permitted. The changes you have made requrie 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 savign changes that require the table to be re-created."
The environment is Windows 7.
I have earlier installed it on a Windows XP SP2 and it worked.
And yes, my table is empty (freshly created).
My current workaround is to run the "Drop and Create" script. The other alternative is to create the primary key before I save the table.
Is this a bug or a limitation with the Express version?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Visual Studio 中有一个选项不允许您保存需要重新创建数据库的更改。如果您取消选中该选项,一切都会正常。
我相信它位于:
工具>选项>数据库工具>表和数据库设计器
在那里,您应该取消选中“防止保存需要重新创建表的更改”或类似的内容。
There is an option in Visual Studio that doesn't allow you to save changes that require Recreating the database. If you un-check that option everything should work.
Off the top of my head I believe it is under:
Tools > Options > Database Tools > Table and Database Designers
There you should un-check the "Prevent Saving Changes that Require Table Recreation" or something similar to this.
使用 SQL Server Express 2012 附带的 SQL Manager Studio:
工具 >选项>设计师>表和数据库设计器
取消选中“防止保存需要重新创建表的更改”
With SQL Manager Studio which is comming with SQL Server Express 2012 :
Tools > Options > Designers > Table and Database Designers
uncheck "Prevent saving changes that require table re-creation"