插入语法错误从excel导入数据

时间:2018-12-11 14:31:14

标签: sql excel ms-access

在短查询中我需要一些帮助我在编写查询时遇到了麻烦,我正在根据Excel工作表上的数据更新表,但一直遇到语法错误

INSERT INTO  [Fleet Commit] ([Commit Type], [Sales Column], [Column1], No, Gender, Style, [Style Descr], Short, [Product Line], Color, Team, [Team Code], Color2, [Logo 1], [Place 1], [Logo 2], [Place 2], [Logo 3], [Place 3], [Logo 4], [Place 4], [Size Scale], [Case Ratio], [Case Ratio Total], [Different Case Ratio], [Approved Whsl], [Suggested Retail], [Customer Whsl], [Customer Retail], [Master Packed? (Y)], [UPC by Size (S) or Carton (C)?], [Solid SKU (S)/ Ratio (R )], [Total Units], [Case Qty], [Total $$], [SAMPLE QTY], [SAMPLE SIZE], [IMAGE REQUEST Y/N], [Licensing Samples])
FROM (SELECT [Commit Type], [Sales Column], [Column1], No, Gender, Style, [Style Descr], Short, [Product Line], Color, Team, [Team Code], Color2, [Logo 1], [Place 1], [Logo 2], [Place 2], [Logo 3], [Place 3], [Logo 4], [Place 4], [Size Scale], [Case Ratio], [Case Ratio Total], [Different Case Ratio], [Approved Whsl], [Suggested Retail], [Customer Whsl], [Customer Retail], [Master Packed? (Y)], [UPC by Size (S) or Carton (C)?], [Solid SKU (S)/ Ratio (R )], [Total Units], [Case Qty], [Total $$], [SAMPLE QTY], [SAMPLE SIZE], [IMAGE REQUEST Y/N], [Licensing Samples]
FROM [Fleet Commit]
IN SCDesktop\Retail SA Fall 19 Master Commit Document - 12062018\Retail SA Fall 19 Master Commit Document - 12062018.xlsx" "EXCEL 5.0;"
GROUP BY  [Commit Type], [Sales Column], [Column1], [No], Gender, Style, [Style Descr], Short, [Product Line], Color, Team, [Team Code], Color2, [Logo 1], [Place 1], [Logo 2], [Place 2], [Logo 3], [Place 3], [Logo 4], [Place 4], [Size Scale], [Case Ratio], [Case Ratio Total], [Different Case Ratio], [Approved Whsl], [Suggested Retail], [Customer Whsl], [Customer Retail], [Master Packed? (Y)], [UPC by Size (S) or Carton (C)?], [Solid SKU (S)/ Ratio (R )], [Total Units], [Case Qty], [Total $$], [SAMPLE QTY], [SAMPLE SIZE], [IMAGE REQUEST Y/N], [Licensing Samples]
ORDER BY  Style);

1 个答案:

答案 0 :(得分:0)

我认为您的错误在这一行:

IN SCDesktop\Retail SA Fall 19 Master Commit Document - 12062018\Retail SA Fall 19 Master Commit Document - 12062018.xlsx"

您还应该删除第一个FROM子句,它不是INSERT INTO命令以及ORDER BY的一部分。应该是这样的:

INSERT INTO [Fleet Commit] ([Commit Type], [Sales Column], [Column1], No, Gender, Style, [Style Descr], Short, [Product Line], Color, Team, [Team Code], Color2, [Logo 1], [Place 1], [Logo 2], [Place 2], [Logo 3], [Place 3], [Logo 4], [Place 4], [Size Scale], [Case Ratio], [Case Ratio Total], [Different Case Ratio], [Approved Whsl], [Suggested Retail], [Customer Whsl], [Customer Retail], [Master Packed? (Y)], [UPC by Size (S) or Carton (C)?], [Solid SKU (S)/ Ratio (R )], [Total Units], [Case Qty], [Total $$], [SAMPLE QTY], [SAMPLE SIZE], [IMAGE REQUEST Y/N], [Licensing Samples])
SELECT [Commit Type], [Sales Column], [Column1], No, Gender, Style, [Style Descr], Short, [Product Line], Color, Team, [Team Code], Color2, [Logo 1], [Place 1], [Logo 2], [Place 2], [Logo 3], [Place 3], [Logo 4], [Place 4], [Size Scale], [Case Ratio], [Case Ratio Total], [Different Case Ratio], [Approved Whsl], [Suggested Retail], [Customer Whsl], [Customer Retail], [Master Packed? (Y)], [UPC by Size (S) or Carton (C)?], [Solid SKU (S)/ Ratio (R )], [Total Units], [Case Qty], [Total $$], [SAMPLE QTY], [SAMPLE SIZE], [IMAGE REQUEST Y/N], [Licensing Samples]
    FROM [Excel 5.0;HDR=Yes;Database=you file path here].[Sheet1$]
    GROUP BY  [Commit Type], [Sales Column], [Column1], [No], Gender, Style, [Style Descr], Short, [Product Line], Color, Team, [Team Code], Color2, [Logo 1], [Place 1], [Logo 2], [Place 2], [Logo 3], [Place 3], [Logo 4], [Place 4], [Size Scale], [Case Ratio], [Case Ratio Total], [Different Case Ratio], [Approved Whsl], [Suggested Retail], [Customer Whsl], [Customer Retail], [Master Packed? (Y)], [UPC by Size (S) or Carton (C)?], [Solid SKU (S)/ Ratio (R )], [Total Units], [Case Qty], [Total $$], [SAMPLE QTY], [SAMPLE SIZE], [IMAGE REQUEST Y/N], [Licensing Samples];