我不断收到“选择”错误,即保留字拼写错误或丢失,或者标点符号不正确,但是我找不到此错误的根源。需要一些帮助。
SELECT Style,
Short,
Color,
[Logo 1],
Forecast,
COMMIT,
Variance
INTO ForecastvsCommitCombined
FROM
(SELECT [FanWalForecastVsCommit].Style,
[FanWalForecastVsCommit].Short,
[FanWalForecastVsCommit].Color,
[FanWalForecastVsCommit].[Logo 1],
[FanWalForecastVsCommit].Forecast,
[FanWalForecastVsCommit].Commit,
[FanWalForecastVsCommit].Variance
FROM [FanWalForecastVsCommit]
UNION ALL SELECT [MeijerForecastVsCommit].Style,
[MeijerForecastVsCommit].Short,
[MeijerForecastVsCommit].Color,
[MeijerForecastVsCommit].[Logo 1], AS [MeijerForecastVsCommit].Forecast,
[MeijerForecastVsCommit].Commit,
[MeijerForecastVsCommit].Variance
FROM [MeijerForecastVsCommit]
UNION ALL SELECT [MidTierForecastVsCommit].Style,
[MidTierForecastVsCommit].Short,
[MidTierForecastVsCommit].Color,
[MidTierForecastVsCommit].[Logo 1],
[MidTierForecastVsCommit].Forecast,
[MidTierForecastVsCommit].Commit,
[MidTierForecastVsCommit].Variance
FROM [MidTierForecastVsCommit]
UNION ALL SELECT [SamsClubForecastVsCommit].Style,
[SamsClubForecastVsCommit].Short,
[SamsClubForecastVsCommit].Color,
[SamsClubForecastVsCommit].[Logo 1],
[SamsClubForecastVsCommit].Forecast,
[SamsClubForecastVsCommit].Commit,
[SamsClubForecastVsCommit].Variance
FROM [SamsClubForecastVsCommit]
UNION ALL SELECT [TargetForecastvsCommit].Style,
[TargetForecastvsCommit].Short,
[TargetForecastvsCommit].Color,
[TargetForecastvsCommit].[Logo 1],
[TargetForecastvsCommit].Forecast,
[TargetForecastvsCommit].Commit,
[TargetForecastvsCommit].Variance
FROM [TargetForecastvsCommit]
UNION ALL SELECT [WalmartForecastVsCommit].Style,
[WalmartForecastVsCommit].Short,
[WalmartForecastVsCommit].Color,
[WalmartForecastVsCommit].[Logo 1],
[WalmartForecastVsCommit].Forecast,
[WalmartForecastVsCommit].Commit,
[WalmartForecastVsCommit].Variance
FROM [WalmartForecastVsCommit]);
答案 0 :(得分:1)
您在语句开头(没有前缀)使用一次保留关键字COMMIT
。您想将该单词括在方括号([]
)中。
在查询中还出现了COMMIT
单词的其他情况,但是由于该单词带有前缀,因此不会产生错误。如果可以,请考虑同时使用方括号。
SELECT Style,
Short,
Color,
[Logo 1],
Forecast,
COMMIT, --> HERE : should be [COMMIT]
Variance
INTO ForecastvsCommitCombined
FROM
(SELECT [FanWalForecastVsCommit].Style,
[FanWalForecastVsCommit].Short,
[FanWalForecastVsCommit].Color,
...
答案 1 :(得分:0)
提交!!!是命令,可能无法使用列名。您需要在名称中加上[commit]
之类的名称