Reputation: 2566
I have this SQL-Server query
UPDATE qryPETEUR_frmPricingModel() SET G&A = '68442.0000' WHERE comp_id = '10004'
Which fails because Incorrect syntax near '&'
The query works when I change the field being edited to something without an ampersand, so I think the ampersand is the problem. Unfortunatly I am stuck having to use the use the field G&A
and can't change it.
What can I do to get this query working. I think I have to escape the ampersand, but I can't figure out how. I have tried adding \ slash in front of it as well as adding ESCAPE '\'
to the end of the query, but nothing worked.
I am also using Code Igniter if that helps.
Upvotes: 1
Views: 1445
Reputation: 700382
You don't escape field names. Put brackets around it:
UPDATE qryPETEUR_frmPricingModel()
SET [G&A] = '68442.0000'
WHERE comp_id = '10004'
Upvotes: 4