Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • When ODBC datasource is a server, how so I specify a database?

    Hello all,

    I have been using the following DO script successfully since you helped me.

    clear
    odbc load, table("client_data") dsn(DBonServer1) noquote
    save "client_data", replace

    There is now a new server: Server2. There are two databases on it: database_a and database_b

    Unlike DBonServer1 driver, AllDBsonServer2, my new ODBC driver, just refers to the server, not to database_a or database_b.

    In my DO script, how do I specify the database for a table?

    I tried:
    odbc load, table("database_a/table1") dsn(AllDBsonServer2) noquote
    and
    odbc load, table("database_a\table1") dsn(AllDBsonServer2) noquote
    It did not work...

    Thanks!



    Last edited by Artur Deguzman; 05 Dec 2023, 16:37.

  • #2
    Originally posted by Artur Deguzman View Post
    In my DO script, how do I specify the database for a table?
    You don't mention what relational database management system you're using, but if it's Microsoft SQL Server, then you can specify the database in a table's three-part name in an odbc load, exec() Stata command.

    For example, assuming that your table is in the dbo schema of the database that you're trying to access, then the following is one approach.
    Code:
    odbc load, exec("SELECT * FROM database_a.dbo.table1;") dsn(AllDBsonServer2)

    Comment

    Working...
    X