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]

st: Re: changeing the database with odbc without using dialog box

From   "Joseph Coveney" <>
To   <>
Subject   st: Re: changeing the database with odbc without using dialog box
Date   Sat, 31 Jul 2010 01:40:26 +0900

Dimitriy V. Masterov wrote:

Is there a way to tell Stata which odbc database to use without going
through the dialog prompt? I am loading some data with:

odbc load, dsn("MIHQDB50") table(tabWeeklyStoreItemPricingAll) clear

This produces the error:

The ODBC driver reported the following diagnostics
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name

This is because the default is to use the database DataWarehouse. When
I use the dialog box to change to database to Orders, where the table
I want is located, everything works, but requires manual effort:

odbc load, dsn("MIHQDB50") table(tabWeeklyStoreItemPricingAll) dialog(prompt);

Is there a way to let Stata know which database I want to use?


Try using the fully specified table name (i.e., Database.owner.Table) in an 
-odbc load, exec()- call.  Assuming that you've assigned table ownership to the
database owner, it would be:

odbc load, exec("SELECT * FROM Orders.dbo.tabWeeklyStoreItemPricingAll;") ///
  dsn(MIHQDB50) clear

I'm curious as to why you're not setting up separate DSNs for each of the
databases . . .

Joseph Coveney

*   For searches and help try:

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