I have a MS Access database (Access 2002, for the record). It has a column whose name contains a question mark, say, for example table "Users" with columns "uid" and "isAdmin?". I need to connect to this database via ODBC, and query for this column, along the following lines:
select [uid], [isAdmin?] from Users order by [isAdmin?];
How do I escape the question mark in the column name, so that the MS Access ODBC driver doesn't think that it's a query parameter? This query doesn't use any parameters, so it's fine if I disable them entirely.
Some limitations:
- I can't easily change the column names.
- I can't easily use something other than ODBC to connect, though this is probably my fallback plan if I can't get ODBC to behave.
- I can't just say
select * from Users
-- it'd still choke on the order by (which is complicated in the real query, so really needs to be done in SQL).
Things I've tried that don't work:
select [uid], '[isAdmin?]' from Users;
-- this makes the second column be the string "[isAdmin?]"select [uid], ['isAdmin?'] from Users;
select [uid], [isAdmin\?] from Users;
select [uid], [isAdmin\?] {escape '\'} from Users;
-- nor does any other escape char work.select [uid], { [isAdmin?] } from Users;
EDIT: I should have clarified, I can't easily change the database much at all, except via ODBC (or ADO or DAO or whatever, but that'll be a bit tricky, and at that point I can just run the query through those).