修复错误的语法错误 [英] Fix incorrect syntax error

查看:113
本文介绍了修复错误的语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在SQL表中输入SQL语句时收到以下消息:

消息156,级别15,状态1,行1

语法不正确关键字'ORDER'附近。



SELECT Part_Number,Supplier,Inspected_By,Reason_For_Inspection,Date_Inspected,Shift,Supplier_Lot_Number,Made_Date,Made_Date_Text,Carton_Box_Serial_Number,& vbCrLf& Total_Time,Qty_Received,Qty_Inspected,Qty_Rejected,Repair_Qty,Repair_Reason,Supplier_IPP_Number,Supplier_IPP_Description,Index_Number,Location,Comments,c004,c005,c007,c008,& vbCrLf&c009,c010,c013,c015,c018,c021, c022,c023,c024,c025,c027,c029,c031,c032,c033,c037,c048,c050,c052,c053,c054,c059,c060,c062,c064,c066,c067p,c069,c070,c072,c073, & vbCrLf&c074,c076,c077,c078,c079,c082,c083,c085,c086,c091,c094,c095,c096,c097,c098,c099,c100,c102,c103,c104,c10 5,c106,c107,c109,c110,c111,c113,c116,c117,c118,c120,& vbCrLf& c122,c123,c125,c126,c129,c132,c145,c148,c149,c151,c152,c154,c155,c156,c157,c158,c159,c160,c161,c162,c163,c164,c999,Time_Entered FROM Sort_Input WHERE((Date_Inspected> = CAST('01/01/2014'as Datetime)AND Date_Inspected< = CAST('07 / 01/2016'as Datetime)AND Inspected_By ='khavens')ORDER BY Part_Number DESC,Inspected_By, Date_Inspected DESC;



我尝试过:



更改位置''和)。

解决方案

使用 SQLFormat - 在线SQL格式化程序 [ ^ ]

you get

 ... 
FROM Sort_Input
WHERE ((Date_Inspected> = CAST(' 01/01/2014' AS 日期时间
AND Date_Inspected< = CAST(' 07/01/2016' AS 日期时间
AND Inspected_By = ' < span class =code-string> khavens')
ORDER BY Part_Number DESC
Inspected_By,
Date_Inspected DESC ;



你看到 WHERE 之后你只需要1 而不是2。


I get the following message when I try to enter the SQL statement in an SQL table:
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'ORDER'.

SELECT Part_Number, Supplier, Inspected_By, Reason_For_Inspection, Date_Inspected, Shift, Supplier_Lot_Number, Made_Date, Made_Date_Text, Carton_Box_Serial_Number," & vbCrLf & " Total_Time, Qty_Received, Qty_Inspected, Qty_Rejected, Repair_Qty, Repair_Reason, Supplier_IPP_Number, Supplier_IPP_Description, Index_Number, Location, Comments, c004, c005, c007, c008, " & vbCrLf & " c009, c010, c013, c015, c018, c021, c022, c023, c024, c025, c027, c029, c031, c032, c033, c037, c048, c050, c052, c053, c054, c059, c060, c062, c064, c066, c067p, c069, c070, c072, c073, " & vbCrLf & " c074, c076, c077, c078, c079, c082, c083, c085, c086, c091, c094, c095, c096, c097, c098, c099, c100, c102, c103, c104, c105, c106, c107, c109, c110, c111, c113, c116, c117, c118, c120, " & vbCrLf & " c122, c123, c125, c126, c129, c132, c145, c148, c149, c151, c152, c154, c155, c156, c157, c158, c159, c160, c161, c162, c163, c164, c999, Time_Entered FROM Sort_Input WHERE ((Date_Inspected >= CAST('01/01/2014' as Datetime) AND Date_Inspected <= CAST('07/01/2016' as Datetime) AND Inspected_By ='khavens') ORDER BY Part_Number DESC, Inspected_By, Date_Inspected DESC;

What I have tried:

Changing position of '"' and ")".

解决方案

Using SQLFormat - Online SQL Formatter[^]
you get

...
FROM Sort_Input
WHERE ((Date_Inspected >= CAST('01/01/2014' AS Datetime)
        AND Date_Inspected <= CAST('07/01/2016' AS Datetime)
        AND Inspected_By ='khavens')
ORDER BY Part_Number DESC,
         Inspected_By,
         Date_Inspected DESC;


and you see that after WHERE you need only 1 ( instead of 2.


这篇关于修复错误的语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆