Error message when you try to save a table in SQL Server 2008: "Saving changes is not permitted"

当使用DDL修改表并尝试保存Microsoft SQL Server 2008中的表时,可能会收到一条消息,指出更改需要表被重新创建。本文详细解释了此问题的原因,并提供了绕过此问题的方法,包括如何使用Transact-SQL语句修改元数据结构,以及更改预设选项的风险。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

SYMPTOMS

When you use Data Definition Language (DDL) to modify a table, and then you try to save the table in Microsoft SQL Server 2008, you may receive the following message:

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 problem occurs when the Prevent saving changes that require the table re-creation option is enabled, and you make one or more of the following changes to the table:
  • You change the Allow Nulls setting for a column.
  • You reorder columns in the table.
  • You change the column data type.
  • You add a new column.
When you change a table so that you alter the metadata structure of the table, and then you save the table, the table must be re-created based on these changes. This may result in the loss of metadata and in a direct loss of data during the re-creation of the table. If you enable the Prevent saving changes that require the table re-creation option in the Designer section of the SQL Server Management Studio (SSMS) Options window, you receive the error message that is mentioned in the "Symptoms" section.
WORKAROUND
To work around this problem, use Transact-SQL statements to make the changes to...To work around this problem, use Transact-SQL statements to make the changes to the metadata structure of a table.

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.
STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are li...
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.
MORE INFORMATION
To change the Prevent saving changes that require the table re-creation option,...To change the Prevent saving changes that require the table re-creation option, follow these steps:
  1. Open SQL Server Management Studio (SSMS).
  2. On the Tools menu, click Options.
  3. In the navigation pane of the Options window, click Designers.
  4. 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.

Risk of turning off the "Prevent saving changes that require table re-creation" option



To determine whether the Change Tracking feature is enabled for a table, follow these steps:
  1. In SQL Server Management Studio, locate the table in Object Explorer.
  2. Right-click the table, and then click Properties.
  3. In the Table Properties dialog box, click Change Tracking.
If the value of the Change Tracking item is True, this option is enabled for the table. If the value is False, this option is disabled.

When the Change Tracking feature is enabled, use Transact-SQL statements to change the metadata structure of the table.

Steps to reproduce the problem

  1. In SQL Server Management Studio, create a table that contains a primary key in the Table Designer tool.
  2. Right-click the database that contains this table, and then click Properties.
  3. In the Database Properties dialog box, click Change Tracking.
  4. Set the value of the Change Tracking item to True, and then click OK.
  5. Right-click the table, and then click Properties.
  6. In the Table Properties dialog box, click Change Tracking.
  7. Set the value of the Change Tracking item to True, and then click OK.
  8. On the Tools menu, click Options.
  9. In the Options dialog box, click Designers.
  10. Click to select the Prevent saving changes that require table re-creation check box, and then click OK.
  11. In the Table Designer tool, change the Allow Nulls setting on an existing column.
  12. Try to save the change to the table.
<think>好的,我现在需要解决用户提到的Verilog错误:“procedural assignment to a non-register result is not permitted”,出现在NumberOfTwo.v文件的第30行。根据用户提供的引用信息,特别是引用2和3,这个问题通常是因为在过程块中对非寄存器类型的变量进行了赋值。 首先,我应该回顾一下Verilog的基本规则。在Verilog中,wire类型变量只能在连续赋值(使用assign语句)或在模块端口连接时使用。而过程块(如always块)中的赋值目标必须是reg类型,即使实际生成的是组合逻辑。这可能是一个常见误区,尤其是对初学者来说,容易混淆reg类型和实际硬件寄存器的关系。 用户提供的错误出现在第30行,所以需要检查该行对应的变量是否被正确声明为reg类型。例如,在引用2中的例子,用户将output_data从wire改为reg,解决了问题。因此,我应该建议用户检查NumberOfTwo.v中第30行赋值的变量是否被声明为reg。 接下来,根据引用3中的建议,组合逻辑和时序逻辑的赋值方式不同。组合逻辑使用阻塞赋值(=),而时序逻辑使用非阻塞赋值(<=)。如果用户在always块中使用了非阻塞赋值但该块描述的是组合逻辑,或者反过来,也可能导致问题。但根据错误信息,这里的问题更可能是变量类型而非赋值符号。 另外,用户可能在always块的敏感列表中没有正确列出所有输入信号,导致推断出的逻辑不正确,但根据错误提示,主要问题还是变量类型。需要确认always块中的敏感列表是否正确,比如是否使用了@(*)来自动捕捉所有相关信号,这在组合逻辑中是推荐的做法。 可能的解决步骤包括: 1. 找到第30行被赋值的变量。 2. 检查该变量是否在模块中声明为reg类型。 3. 如果不是,将其声明改为reg。 4. 确认always块中的赋值方式是否正确(组合逻辑用=,时序用<=)。 5. 确保敏感列表正确,比如组合逻辑使用@(*)。 此外,用户可能没有正确区分组合逻辑和时序逻辑的结构。例如,在组合逻辑中,如果没有覆盖所有条件分支,可能会导致锁存器的推断,但这可能与当前错误无关,但也是需要注意的地方。 最后,用户可能需要检查是否有其他类似的变量在过程块中被错误地赋值而没有声明为reg类型,或者是否在多个always块中对同一变量进行了赋值,导致冲突。</think>### 问题分析:Verilog过程赋值错误 错误信息 `procedural assignment to a non-register result is not permitted` 表示在 **过程块(如 `always` 块)** 中对一个未声明为 `reg` 类型的变量进行了赋值。以下是逐步解决方案: --- #### 1. **确认变量声明类型** - **问题根源**:在 `always` 块中赋值的变量必须是 `reg` 类型,即使它实际代表组合逻辑而非寄存器。 - **检查代码**:定位到 `NumberOfTwo.v` 的第30行,确认被赋值的变量(例如 `output_data`)是否声明为 `reg`。 - **错误示例**: ```verilog output wire [3:0] result // 错误!wire类型不能在always块中赋值 ``` - **正确修改**: ```verilog output reg [3:0] result // 改为reg类型 ``` --- #### 2. **区分组合逻辑与时序逻辑** - **组合逻辑**:使用 `always @(*)` 和 **阻塞赋值(`=`)**。 ```verilog always @(*) begin result = (condition) ? a : b; // 阻塞赋值 end ``` - **时序逻辑**:使用 `always @(posedge clk)` 和 **非阻塞赋值(`<=`)**。 ```verilog always @(posedge clk) begin result <= a + b; // 非阻塞赋值 end ``` --- #### 3. **检查敏感列表** - **组合逻辑必须包含所有输入信号**,推荐使用 `always @(*)` 自动推断敏感列表: ```verilog always @(*) begin // 自动包含所有相关信号 // 组合逻辑代码 end ``` --- #### 4. **常见错误场景** - **错误**:在 `always` 块中对 `wire` 类型赋值。 ```verilog wire [3:0] count; always @(*) begin count = input_a + input_b; // 错误!count必须是reg类型 end ``` - **修复**: ```verilog reg [3:0] count; // 声明为reg类型 always @(*) begin count = input_a + input_b; // 正确 end ``` --- ### 相关问题 1. **如何避免Verilog中组合逻辑生成锁存器?** - 需确保 `always` 块中所有条件分支完整覆盖,未覆盖时默认保持原值会导致锁存器[^3]。 2. **`reg` 类型变量是否一定会综合成寄存器?** - 不一定。`reg` 在组合逻辑中会被综合为连线,仅在时序逻辑中才会推断为寄存器[^2]。 3. **如何调试Verilog仿真中的死循环问题?** - 检查敏感列表是否遗漏信号,或组合逻辑中未覆盖的分支导致信号不稳定[^1]。 --- ### 总结 - **核心规则**:过程赋值目标必须是 `reg` 类型。 - **代码分层**:组合逻辑与时序逻辑分开设计,避免混用赋值方式。 - **仿真调试**:若仿真异常终止,需检查代码中是否有未处理的条件分支或死循环[^4]。 : 引用1 : 引用2 : 引用3 : 引用4
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值