Reputation: 127
I have a table with a column name as "key". I am unable to filter based on that column
select * from myTable where key='someVal'
I get the following error
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'key'.
I cannot change the column name. How I can circumvent this issue?
Upvotes: 0
Views: 27
Reputation: 3266
It's because key
is a keyword. If you have keywords as object names, you need to put them in brackets:
select * from myTable where [key]='someVal'
Upvotes: 1