Access 2010:该字段太小,无法接受您尝试添加的数据量 WITHOUT DISTINCT
Posted
技术标签:
【中文标题】Access 2010:该字段太小,无法接受您尝试添加的数据量 WITHOUT DISTINCT【英文标题】:Access 2010: the field is too small to accept the amount of data you attempted to add WITHOUT DISTINCT 【发布时间】:2012-07-09 14:42:48 【问题描述】:我知道关于此访问错误消息有几个问题,但它们不相关,因为我的查询没有使用 DISTINCT 关键字。
我有两个类似的查询,一个包含贷方,另一个包含借方。它们按月份和类别分组。
最终,我希望在这两个表上进行完全外部联接,这样我就可以减去它们以获得每个类别中每个月的结果余额。
但是 Access 不允许完全外连接,所以我需要做一个 Right OUTER UNION LEFT OUTER WHERE Null。
我现在正在尝试在 Month 和 Category ID 字段上进行 RIGHT OUTER 连接。当我在一个字段上进行外部连接时,它按预期工作。当我在另一个字段上执行此操作时,它按预期工作,但是当我加入两个字段时,我得到“该字段太小,无法接受您尝试添加的数据量”
表 1:
制作者:
SELECT [transactions by category].[categoryid] AS CategoryID,
Format([account transactions].[transaction date], "mm/yy") AS MonthYear,
Nz(SUM([transactions by category].[amount]), 0) AS
[Category Total]
FROM [transactions by category]
INNER JOIN [account transactions]
ON [account transactions].[id] =
[transactions by category].[transactionid]
WHERE [account transactions].[transaction type] <> 8
GROUP BY Format([account transactions].[transaction date], "mm/yy"),
[transactions by category].[categoryid];
表 2:
制作者:
SELECT [transactions by category].[categoryid],
Format([account transactions].[transaction date], "mm/yy") AS MonthYear,
Nz(SUM([transactions by category].[amount]), 0) AS
[Category Total]
FROM [transactions by category]
INNER JOIN [account transactions]
ON [account transactions].[id] =
[transactions by category].[transactionid]
WHERE [account transactions].[transaction type] = 8
GROUP BY Format([account transactions].[transaction date], "mm/yy"),
[transactions by category].[categoryid];
给我错误的正确连接:
SELECT * FROM
((SELECT [transactions by category].[categoryid],
Format([account transactions].[transaction date], "mm/yy")
AS MonthYear,
Nz(SUM([transactions by category].[amount]), 0) AS [Category Total]
FROM [transactions by category]
INNER JOIN [account transactions]
ON [account transactions].[id] =
[transactions by category].[transactionid]
WHERE [account transactions].[transaction type] = 8
GROUP BY Format([account transactions].[transaction date], "mm/yy"),
[transactions by category].[categoryid]) AS [Category Returns]
RIGHT JOIN
(SELECT [transactions by category].[categoryid] AS CategoryID,
Format([account transactions].[transaction date], "mm/yy")
AS MonthYear,
Nz(SUM([transactions by category].[amount]), 0) AS [Category Total]
FROM [transactions by category]
INNER JOIN [account transactions]
ON [account transactions].[id] =
[transactions by category].[transactionid]
WHERE [account transactions].[transaction type] <> 8
GROUP BY Format([account transactions].[transaction date], "mm/yy"),
[transactions by category].[categoryid]) AS [Category Debits]
ON [Category Returns].[categoryid] = [Category Debits].[categoryid]
AND [Category Returns].[monthyear] = [Category Debits].[monthyear] );
似乎此错误发生在文本字段中。当我使用格式时,MonthYear 字段是否会变为文本字段?即便如此,它也只有 5 个字符长。另外,当我仅在 MonthYear 列上加入时,连接有效,但只有在我同时加入两个字段时才会失败。
【问题讨论】:
这被标记为 2007,但标题显示 2010。它是什么? 【参考方案1】:根据您的标签,您正在使用 SQL 服务器作为后端。您遇到的问题不是来自 MS Access,而是来自 MS Access 和 SQL Server 的组合。该查询将在纯 MS Access 环境中工作。 (是的,格式确实会转换为文本。)
您可以使用 pass-through queries 创建一个使用 SQL Server 语法运行的查询,因此您可以使用完全外连接,或者您可能希望考虑 http://weblogs.sqlteam.com/jeffs/archive/2007/04/19/Full-Outer-Joins.aspx
编辑重新更改标签
如果您的某个字段是备注字段,请参阅http://support.microsoft.com/kb/896950。在这样的复杂查询中,最好将备注字段缩减到 255 或更少。
【讨论】:
+1 如果所有这些表都驻留在 SQL Server 上,那么如果您可以使用,我会选择 Remou 的第二个选项。它也应该比链接 SQL Server 表上的 Access 查询提供更好的性能。 @MattDonnan 只有一个选项,在混合环境中查询将不起作用。 这不是 SQL Server。我不知道我说了什么,但这是一个严格的 MS Access 2007 数据库。不过,我仍在研究该链接,看看这是否是一个好的解决方案。 @user1068058 你的标签说 SQL Server。我在 MS Access 中使用了一个非常相似的查询(即使用 Jet/ACE)进行了测试,它对我有用。以上是关于Access 2010:该字段太小,无法接受您尝试添加的数据量 WITHOUT DISTINCT的主要内容,如果未能解决你的问题,请参考以下文章
错误 - 字段太小,无法接受您尝试添加的数据量。尝试插入或粘贴更少的数据