我有一个链接到另一个访问数据库的访问数据库。在后者中,有一个托管在SQL服务器上的表。我曾经把它放在本地表上,并且对查询没有任何问题,但现在它在SQL上,我不断收到错误。帮助会很棒!
SELECT Year([date]) AS [YEAR],
Month([date]) AS [MONTH],
[bear revenue].[CustomerNum],
Iif([customernum] LIKE "g*", 99999999,
Iif([customernum] LIKE "*w*", Replace([customernum], "0w", 99), Iif(
[customernum] LIKE "*i*", Replace([customernum], "0i", 98), Iif(
[customernum] LIKE "*-*", LEFT(
[customernum], 5), [customernum])))) AS
[Customer No],
[bear revenue].asc,
[bear revenue].account,
[bear revenue].department,
[bear revenue].[FeeType],
Sum([bear revenue].[Loan_Count]) AS
[SumOfLOAN COUNT],
Sum([bear revenue].revenue) AS
SumOfREVENUE,
Sum(Iif([refund rate] <> 0, [loan_count] * [refund rate], 0)) AS refund,
[bear revenue].system
FROM bear Revenue
LEFT JOIN [current customer refunds]
ON ( [bear revenue].[CustomerNum] =
[current customer refunds].[refund customer numbers] )
AND ( [bear revenue].[FeeType] =
[current customer refunds].[feetype] )
GROUP BY Year([date]),
Month([date]),
[bear revenue].[CustomerNum],
Iif([customernum] LIKE "g*", 99999999,
Iif([customernum] LIKE "*w*", Replace([customernum], "0w", 99), Iif(
[customernum] LIKE "*i*", Replace([customernum], "0i", 98), Iif(
[customernum] LIKE "*-*", LEFT(
[customernum], 5), [customernum])))),
[bear revenue].asc,
[bear revenue].account,
[bear revenue].department,
[bear revenue].[FeeType],
[bear revenue].system
HAVING ( ( ( Year([date]) ) = 2013 )
AND ( ( Month([date]) ) = 10 ) )
ORDER BY Year([date]),
Month([date]),
[bear revenue].[CustomerNum],
Iif([customernum] LIKE "g*", 99999999,
Iif([customernum] LIKE "*w*", Replace([customernum], "0w", 99), Iif(
[customernum] LIKE "*i*", Replace([customernum], "0i", 98), Iif(
[customernum] LIKE "*-*", LEFT(
[customernum], 5), [customernum])))),
[bear revenue].asc,
[bear revenue].account,
[bear revenue].[FeeType];
答案 0 :(得分:0)
如果您发布了错误,它会有所帮助。但是,from
子句中的查询似乎存在明显问题。
你在哪里:
FROM Bear Revenue
你应该
FROM [Bear Revenue]
如果这是远程表,您可能还想要包含数据库和模式名称。
答案 1 :(得分:0)
对关键字asc
SELECT Year([date]) AS [YEAR],
Month([date]) AS [MONTH],
[bear revenue].[CustomerNum],
Iif([customernum] LIKE "g*", 99999999,
Iif([customernum] LIKE "*w*", Replace([customernum], "0w", 99), Iif(
[customernum] LIKE "*i*", Replace([customernum], "0i", 98), Iif(
[customernum] LIKE "*-*", LEFT(
[customernum], 5), [customernum])))) AS
[Customer No],
[bear revenue].[asc],
[bear revenue].account,
[bear revenue].department,
[bear revenue].[FeeType],
Sum([bear revenue].[Loan_Count]) AS
[SumOfLOAN COUNT],
Sum([bear revenue].revenue) AS
SumOfREVENUE,
Sum(Iif([refund rate] <> 0, [loan_count] * [refund rate], 0)) AS refund,
[bear revenue].system
FROM bear Revenue
LEFT JOIN [current customer refunds]
ON ( [bear revenue].[CustomerNum] =
[current customer refunds].[refund customer numbers] )
AND ( [bear revenue].[FeeType] =
[current customer refunds].[feetype] )
GROUP BY Year([date]),
Month([date]),
[bear revenue].[CustomerNum],
Iif([customernum] LIKE "g*", 99999999,
Iif([customernum] LIKE "*w*", Replace([customernum], "0w", 99), Iif(
[customernum] LIKE "*i*", Replace([customernum], "0i", 98), Iif(
[customernum] LIKE "*-*", LEFT(
[customernum], 5), [customernum])))),
[bear revenue].[asc],
[bear revenue].account,
[bear revenue].department,
[bear revenue].[FeeType],
[bear revenue].system
HAVING ( ( ( Year([date]) ) = 2013 )
AND ( ( Month([date]) ) = 10 ) )
ORDER BY Year([date]),
Month([date]),
[bear revenue].[CustomerNum],
Iif([customernum] LIKE "g*", 99999999,
Iif([customernum] LIKE "*w*", Replace([customernum], "0w", 99), Iif(
[customernum] LIKE "*i*", Replace([customernum], "0i", 98), Iif(
[customernum] LIKE "*-*", LEFT(
[customernum], 5), [customernum])))),
[bear revenue].[asc],
[bear revenue].account,
[bear revenue].[FeeType];
答案 2 :(得分:0)
您的前端数据库中有一个名为[Bear Revenue]的表链接,指向后端数据库中名为[Bear Revenue]的 Access表 。将[Bear Revenue] Access表移动到SQL Server(并将其替换为后端到SQL Server表的链接)后,名为[Bear Revenue]的 实际Access表不再存在 在后端数据库中。这就是您的前端数据库文件中的[Bear Revenue]表链接停止工作的原因。
解决方案是删除前端数据库中的当前(Access)[Bear Revenue]表链接,并将其替换为直接指向SQL Server表的ODBC表链接(也称为[Bear Revenue])。