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
  • 34,979
  • 10
  • 68
  • 73
CPDS
  • 597
  • 2
  • 6
  • 18

3 Answers3

2

Enclose keywords in brackets:

SELECT * FROM table1 WHERE [OBJECT] = '11'
PaulStock
  • 11,053
  • 9
  • 49
  • 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
  • 450,073
  • 74
  • 686
  • 939
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,669
  • 31
  • 105
  • 183