1

Hi I have a table which contains filed name as OBJECT.
I am trying to fetch records from the table using select query as follows:

SELECT * 
  FROM table1 
 WHERE OBJECT = "11";

I am getting the following error - INVALID COLUMN NAME.
Looks like its reading OBJECT as SQL KEYWORD and not as table field name.

I am writing this query in sql server management studio.

Vincent Savard
  • 32,695
  • 10
  • 65
  • 72
CPDS
  • 587
  • 2
  • 6
  • 18

3 Answers3

2

Enclose keywords in brackets:

SELECT * FROM table1 WHERE [OBJECT] = '11'
PaulStock
  • 10,663
  • 9
  • 46
  • 52
0

Try

select * from table1 where [OBJECT] = '11';

MSDN: Delimited Identifiers

Btw, here is another SO-question to this issue.

Community
  • 1
  • 1
Tim Schmelter
  • 429,027
  • 67
  • 649
  • 891
0

Use single quotation marks. But if object is numeric, don't use any quotation marks around the number 11.

             where mycol = 'x'  

             not 

           where mycol = "x"
Tim
  • 8,227
  • 30
  • 100
  • 173