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 ")".