Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2004
    Posts
    91

    Unanswered: copy a table using sql

    Hi Everyone -

    I need to create a temp database based on the schema
    of an existing table...

    how do i accomplish this in SQL??

    I was thinking something like....

    create table tbladt_copy select * from tbladt where 1=0

    ASA 7

    thanks

  2. #2
    Join Date
    Feb 2002
    Location
    Willy is on vacation
    Posts
    1,208
    There is a dbunload utility that is in your win32 and also available via the Sybase Central "utilities" folder. The wizard will walk you through the process. It is very straight forward.

    Once you have your schema unloaded, create a new instance on the same server using dbinit utility and then in Interactive sql;
    READ 'C:\\reload.sql'

    You can achieve this in sql, by having the second database as proxy on the source.
    Last edited by willy_and_the_ci; 11-01-05 at 19:08.

  3. #3
    Join Date
    Oct 2004
    Posts
    91

    t-sql way

    Thanks for the reply -

    I am trying to complete the task via a script...

    all those command line tools are nice,
    but i would like to create a new empty table
    based on the schema of an existing table
    using t-sql (script)

    sorry to mislead you

    thanks again for the reply.

    take care
    tony

  4. #4
    Join Date
    Jan 2003
    Location
    Geneva, Switzerland
    Posts
    353
    The normal method in T-SQL is:


    select ... into NEW_TABLE
    from OLD_TABLE where 1=0

    Michael

  5. #5
    Join Date
    Oct 2004
    Posts
    91

    tried

    tried that syntax....

    only works for temp tables in ASA 7


    thanks for the reply


    take care
    tony

  6. #6
    Join Date
    Jan 2003
    Location
    Geneva, Switzerland
    Posts
    353
    I don't know ASA - with ASE you have to enable the "select into" option for the database. Maybe ASA has a similar configuration parameter?

    Michael

  7. #7
    Join Date
    Feb 2002
    Location
    Willy is on vacation
    Posts
    1,208
    ASA each database is a seperate instance. Although you can start all the databases under a single engine. To copy from one to another database, you either need to use the proxy services or via the utility that I mentioned before.

  8. #8
    Join Date
    Oct 2004
    Posts
    91

    Completed

    Sorry it took so long to post a response

    i couldn't find a way to copy the schema of a table
    into a new table under ASA 7

    so in the script, i created a copy table based on the
    script used to create the original table -

    and at the end of the script, i drop the copy table.

    worked like a champ

    thanks for the replies

    take care
    tony

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •