user3115214
user3115214

Reputation: 11

SQL Query "Syntax error near field"

I am using a middleware system to connect to a Database system. We are using a lookup functionality which in turn creates an SQL Query based on the conditions we have provided in it.

SQL QUERY CREATED:

SELECT "FunctionCode", "AUM", "Numerator", "Denominator", "EANUPC", "Length", "Width", "Height", "CategoryofEAN" FROM "tblIdocAlternateUOMs" WHERE MaterialNumber='09792021'

Error:

'Error processing request in sax parser: Error when executing statement for table/stored proc. 'table' (structure 'statement'): com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'FunctionCode'.'.

I have executed the above query in database system and it is working fine without the errors but I am seeing the error in my system when I am trying to retrieve the data from DB.

DB System : Microsoft SQL SERVER

Could you please let me know why are these kind of errors usually appear?

Upvotes: 0

Views: 1616

Answers (1)

The Hungry Dictator
The Hungry Dictator

Reputation: 3484

SELECT 
     FunctionCode, 
     AUM, 
     Numerator, 
     Denominator,
     EANUPC, 
     Length, 
     Width, 
     Height, 
     CategoryofEAN 
FROM 
     tblIdocAlternateUOMs 
WHERE 
     MaterialNumber='09792021'

one thing keep in mind that only value needs quotation mark and that is single quotes... nor field name...

Remove that quotation mark from coding side query.... Just because of this its hapening

Upvotes: 13

Related Questions