I need a table that stores key-value pairs, so I created one with a column called "Key" and a column called "Value".
This fails:
insert into mykeyvalues (Key,Value) values ('FooKey', 'FooValue')
"Incorrect syntax near the keyword 'key'."
Maybe I shouldn't call it "Key", but I just wonder if it is possible to work with a column whose name is a sql keyword?
Thanks
You can surround column names like that with [ ] brackets. Therefore:
insert into mykeyvalues ([Key],[Value]) values ('FooKey', 'FooValue')
Use either backticks (`) or double quotes (") around the identifiers in your query. For example:
INSERT INTO mykeyvalues ("Key", "Value") values ('FooKey', 'FooValue')
But in the long-run, this just reduces portability. It's easier to use a different name.