Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: odbc load SQL

From   Jen Zhen <>
Subject   Re: st: odbc load SQL
Date   Thu, 26 Apr 2012 16:15:36 +0200

The strange thing is that when I type
   odbc load var1 var2, table("`table1'")
Stata tells me
   table() or exec() is required
even though I had in fact specified table.
Or did I somehow get the syntax of it wrong?

On Thu, Apr 26, 2012 at 3:39 PM, Jen Zhen <> wrote:
> Dear Statalisters,
> I am trying to load a dataset (or, for size reasons, parts of it) from
> SQL into Stata.
> I got as far as typing
>   local db "DRIVER={MySQL ODBC 5.1
> Driver};SERVER=my_server;DATABASE=my_database;UID=jenzhen;PWD=jenzhenspassword;"
>   local sql "SHOW tables"
>   odbc load, exec("`sql'") conn("`db'") clear
>   br
> which shows me a list of all tables in the database "my_database":
> Tables_in_my_database", "table1" and "table2".
> However, I don't manage to open one of these tables. I typed
>   odbc load, table(table1) conn("`db'") clear
> which I thought should load table1 into memory, but Stata then just tells me:
>   The ODBC driver reported the following diagnostics
>   [MySQL][ODBC 5.1 Driver][mysqld-5.1.30]You have an error in your
> SQL syntax; check the manual that corresponds to your
>   MySQL server version for the right syntax to use near 'table1' at line 1
>   SQLSTATE=42000
> Might anyone be able to tell me what I'm getting wrong here?
> Thanks so much and best regards,
> JZ
> *
> *   For searches and help try:
> *
> *
> *

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index