当不存在验证规则时,由于验证错误而附加查询失败 (Access)
Append query failing due to validation errors when no validation rules exist (Access)
我正在尝试在 Access 2013 中将数据从一个 table 附加到另一个。目标 table、[ActionItems]
还没有记录。
源 table、[Students]
具有必要的列:[AutoID]
(自动编号)、[Action Status]
(短文本)、[Action Status Last Updated]
(Date/time), [Action Status Description]
(短文本).
我已经设置目标 table 以匹配数据类型和字段(虽然字段名称略有不同,但我已在追加查询中适当地加入了它们)。目标 table 中的 [AutoID]
字段设置为数字,长整型,正如我在其他地方读到的建议。
如果我在数据表视图中查看追加查询,我会看到 731 条记录,这是我应该看到的。但是当我尝试 运行 查询时,出现以下错误:
"Microsoft Access can't append all the records... set 0 field(s) to
Null due to a type conversion failure... 0... key violations... 0...
lock violations, and 731 record(s) due to validation rule
violations."
目标 table 中有 NO 条验证规则!两个文本字段都允许零长度,并且 [AutoID]
字段没有默认值。我不明白我可能遗漏了什么。
这是我的SQL(我意识到我的专栏名称相当冗长):
INSERT INTO [ActionItems] ( AutoID, [Action Status], [Action Status Last Updated], [Action Status Description] )
SELECT [Students].[AutoID (Do not use)], [Students].Status, [Students].[Status Last Updated], [Students].[Status Description]
FROM [Students];
如果有帮助,这里是 link 数据库的精简版本:https://drive.google.com/file/d/0BysgnYaEVPnJemNnOUc3ZmFsWXM/view?usp=sharing
我已删除所有其他 table 和任何可识别信息。唯一的其他主要区别是 [Students]
table 中的主键从复合键([First Name]
、[Last Name]
和 [Email]
)更改为单个主键 ([AutoID (Do not use)]
)。我对 [ActionItems]
table 没有做任何更改。即使进行了这些更改,错误仍然如前所述发生。
目的地 table、ActionItems
包含一个名为 Action Status Last Updated By
的字段。该字段的 Required 属性 设置为 Yes,其 Default Value 属性 为空。这意味着任何时候您向 table 添加新行时,您 必须 为 Action Status Last Updated By
.
提供一个值
请注意您的 INSERT
声明没有为 Action Status Last Updated By
提供任何内容。因此 INSERT
不会添加任何行。
在我的数据库副本中,我将字段的 Required 属性 更改为 No。在该更改之后,执行您的 INSERT
查询向 ActionItems
添加了 731 行...... Students
.
中的每一行。
如果您更喜欢不同的解决方案,您可以将 Required 设置为 True 并在字段的 默认值 属性 或更改 INSERT
以为该字段提供值。
我正在尝试在 Access 2013 中将数据从一个 table 附加到另一个。目标 table、[ActionItems]
还没有记录。
源 table、[Students]
具有必要的列:[AutoID]
(自动编号)、[Action Status]
(短文本)、[Action Status Last Updated]
(Date/time), [Action Status Description]
(短文本).
我已经设置目标 table 以匹配数据类型和字段(虽然字段名称略有不同,但我已在追加查询中适当地加入了它们)。目标 table 中的 [AutoID]
字段设置为数字,长整型,正如我在其他地方读到的建议。
如果我在数据表视图中查看追加查询,我会看到 731 条记录,这是我应该看到的。但是当我尝试 运行 查询时,出现以下错误:
"Microsoft Access can't append all the records... set 0 field(s) to Null due to a type conversion failure... 0... key violations... 0... lock violations, and 731 record(s) due to validation rule violations."
目标 table 中有 NO 条验证规则!两个文本字段都允许零长度,并且 [AutoID]
字段没有默认值。我不明白我可能遗漏了什么。
这是我的SQL(我意识到我的专栏名称相当冗长):
INSERT INTO [ActionItems] ( AutoID, [Action Status], [Action Status Last Updated], [Action Status Description] )
SELECT [Students].[AutoID (Do not use)], [Students].Status, [Students].[Status Last Updated], [Students].[Status Description]
FROM [Students];
如果有帮助,这里是 link 数据库的精简版本:https://drive.google.com/file/d/0BysgnYaEVPnJemNnOUc3ZmFsWXM/view?usp=sharing
我已删除所有其他 table 和任何可识别信息。唯一的其他主要区别是 [Students]
table 中的主键从复合键([First Name]
、[Last Name]
和 [Email]
)更改为单个主键 ([AutoID (Do not use)]
)。我对 [ActionItems]
table 没有做任何更改。即使进行了这些更改,错误仍然如前所述发生。
目的地 table、ActionItems
包含一个名为 Action Status Last Updated By
的字段。该字段的 Required 属性 设置为 Yes,其 Default Value 属性 为空。这意味着任何时候您向 table 添加新行时,您 必须 为 Action Status Last Updated By
.
请注意您的 INSERT
声明没有为 Action Status Last Updated By
提供任何内容。因此 INSERT
不会添加任何行。
在我的数据库副本中,我将字段的 Required 属性 更改为 No。在该更改之后,执行您的 INSERT
查询向 ActionItems
添加了 731 行...... Students
.
如果您更喜欢不同的解决方案,您可以将 Required 设置为 True 并在字段的 默认值 属性 或更改 INSERT
以为该字段提供值。