We help IT Professionals succeed at work.

Need help with run time error 3075 - syntax error for SQL Statement.

stephenlecomptejr
on
74 Views
Last Modified: 2018-12-20
Need help with identifying syntax error:

Here's the output of SQL string:

DELETE tempTimesheetWeek.PMHours, tempTimesheetWeek.AMHours, tempTimesheetWeek.[08WorkDate], tempTimesheetWeek.[01WorkDate] FROM tempTimesheetWeek WHERE (tempTimesheetWeek.PMHours = 0 Or tempTimesheetWeek.PMHours IsNull)  AND tempTimesheetWeek.AMHours >0 AND tempTimesheetWeek.[01WorkDate] = #12/13/2018#

Open in new window


Please note image of syntax error message
sql-syntax-msg.PNG
Comment
Watch Question

CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
ste5anSenior Developer
CERTIFIED EXPERT

Commented:
Simplify it:

DELETE FROM tempTimesheetWeek
WHERE Nz(PMHours, 0) = 0 AND AMHours > 0 AND [01WorkDate] = #12/13/2018#;

Open in new window

Anders Ebro (Microsoft MVP)Microsoft Developer
CERTIFIED EXPERT

Commented:
Just to be clear, you cannot delete specific fields in a table. You delete ROWS, i.e. the entire row.
Other than that, I would stick to using Is Null, which is plan SQL and doesn't involving function calls. It is faster.

DELETE FROM tempTimesheetWeek WHERE (tempTimesheetWeek.PMHours = 0 Or tempTimesheetWeek.PMHours Is Null)  AND tempTimesheetWeek.AMHours >0 AND tempTimesheetWeek.[01WorkDate] = #12/13/2018#

Open in new window

Author

Commented:
Appreciate everyone's replies.  Thanks for the help!
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.