BAQ Severity: Error, Text: Bad SQL statement

Hello,

I have a BAQ that is giving me the error “Severity: Error, Text: Bad SQL statement.”

It was fine until I added a certain Phrase.

I had ERP.Customer, ERP.OrderDtl, and ERP.OrderHed.

But when I added ERP.SerialNo I got that error.

image

I believe your event viewer on the server will tell you the sql error.

I have to ask IT for that, so I apologize for not having it immediately.

I seemed to have fixed it by adding ERP.Part which then connected to ERP.SerialNo.

Nevermind, it stopped working. I will post the log when I receive it.

Why are you joining serial number to customer? That doesn’t seem to make sense.

Good point. This is what I have now but still giving me an error:


image

That still doesn’t make sense…

You should have:
customer → company and custnum to orderhead
OrderHed → company and ordernum to orderDtl
OrderDtl → company, custnum and partNum to serialNo
SerialNo

Unless you are getting some other data for part, you don’t need the part table.

So this is what I have now, unfortunately still giving me an error:


image

ok, so we at least have a BAQ that makes sense.

Usually that error is some weird data in the table. Can you try just returning 1 row and see if you still get the error?

Here:

So it works, there is just something in your data that’s an illegal character. I would guess it’s in the serial numbers, are those serial numbers copy/pasted from somewhere else?

Do you mean the part numbers? I took those out.

As for the serial numbers, I am not sure how they’re implemented. A few people have access to creating them. I don’t personally copy and past them, but it could be possible others have.

Could be either. Usually illegal characters get introduced by copy pasting from somewhere else, like the web, or excel etc. To troubleshoot, remove a field at a time (leave the tables as is) from what’s being displayed, and see if the error goes away.

I don’t know how your orders are being created either, but it’s possible the part numbers there (on order Detail) could be messed up. Less likely, but possible.

1 Like

I needed to give me three customers, so after putting in a date parameter and customer IDs to retrieve, it stopped that error. Weird.

Thank you for your help!

It’s probably because we arranged the tables in a logical way. The way you had it before, it was going to pull a bunch of stuff then remove them from the list, so somewhere in that list, there’s a bad character.

You really should see if you can find that so you can fix it, even if you don’t need it now, it will bite you later.

1 Like