[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: WHERE SQL clause
Alberto Tosetto, M.D. <email@example.com> wrote:
>I am having a problem with the odbc command on Stata 8.0. When I use
>the exec("...") option in the odbc load command, everything works fine
>provided that the SQL WHERE statement does not address VARCHAR values.
>For instance, if I try the following SQL statement
>SELECT * FROM MYTABLE, WHERE GENDER="F"
>Stata gives me back the following message: table() or exec() is required
The short answer is to use single quotes for any quoted value in your SQL
SELECT * FROM MYTABLE, WHERE GENDER='F'
Most ODBC Drivers, and the SQL servers they connect to, actually prefer single
quotes within SQL commands. All SQL servers we have tested take both single
and double as interchangeable. The Stata command line parser, however, does
not identify double quotes as valid syntax at this time so you will be required
to use single quotes.
In the near future Stata will most likely either 1) support double quotes in
a way that is compatible with all SQL servers, or 2) display a better error
message if the Stata parser doesn't support double quotes.
* For searches and help try: