7

I'm trying to query a collection for some documents where one of the fields happens to be named 'top'. However, I can't directly reference this column in a select statement because the name conflicts with the TOP keyword. For example:

SELECT C.code, C.top FROM c

This throws the following error - "Syntax error, incorrect syntax near 'top'."

Is there anything I can do to escape this field name, or will I have to rename the field to something else?

Kirk Larkin
  • 84,915
  • 16
  • 214
  • 203
Adam Greenall
  • 189
  • 2
  • 10

1 Answers1

21

top is a reserved keyword. To escape this use [""] syntax.

SELECT  c.code,c["top"] FROM c
Sajeetharan
  • 216,225
  • 63
  • 350
  • 396