Announcement

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

  • Inserting Data into Table Using ODBC, Insert

    Hi there,

    I've noticed that when I insert a table into a SQL database using odbc, insert, the table schema defaults to my username. Is there a way for Stata to specify the schema for the table being inserted, or is that handled elsewhere?

    Thanks,
    Erika

  • #2
    If you mean a Microsoft SQL Server database, then you can qualify the table name with the schema name. For example, to create the table in the schema other_schema. assuming that the schema has already been created and that you have permission to create a table in it, you could
    Code:
    sysuse autos
    rename foreign nondomestic
    odbc insert, table("other_schema.Automobiles") dsn(<your dsn>) create
    odbc exec("EXECUTE sp_help 'other_schema.Automobiles';"), dsn(<your dsn>)

    Comment

    Working...
    X