1

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.

Matt Urtnowski
  • 2,556
  • 1
  • 18
  • 36

1 Answers1

4

You don't escape field names. Put brackets around it:

UPDATE qryPETEUR_frmPricingModel()
SET [G&A] = '68442.0000'
WHERE comp_id = '10004'
Guffa
  • 687,336
  • 108
  • 737
  • 1,005