copying table

  • oops i was trying to create index on the table authors in pubs database, there it didn't allow me hence decided to create a copy of authors and try n it...(this is the scenario)

    Tried Bulk copy statement but seems to be working only for files to table copying, is there anyway i can create a table named authors_copy with the datas of authors in it.

    Regards

    Arun


    Kindest Regards,

    Arunkumar

    Reputation is what other people know about you. Honor is what you know about yourself."--

  • Hi

    Right Mouse the table, select All Tasks>Export Data

    Follow the wizard through, and just change the destination table name to authors_copy.

     

  • Thanks Russell!

    My requirement is to do it through a query...

    Regards

    Arun 


    Kindest Regards,

    Arunkumar

    Reputation is what other people know about you. Honor is what you know about yourself."--

  • in Tsql you can use the select into method jsut for testing messing round type stuff.

    select *

    Into Authors_Copy

    from Authors

    Other wise I recommend you create the table definition first

    Create table MyTable (..

    )

    Then insert

    Insert into MyTable(.....)

    Select ...

    from Authors

     

  • Thanks a ton Ray, the first one worked like a bub.

    But i faltered in trying the second option...created the table sales_copy (copy of sales in pubs database)

    here is the sql query...make the amendments on the below query to make it work

    create table sales_copy (stor_id char(5),ord_num varchar(5),ord_date datetime default getdate(), qty smallint,payterms varchar(5),title_id varchar(5))

    insert into sales_copy(stor_id,ord_num,ord_date,qty,payterms,title_id) select(stor_id,ord_num,ord_date,qty,payterms,title_id) from sales


    Kindest Regards,

    Arunkumar

    Reputation is what other people know about you. Honor is what you know about yourself."--

  • Your syntax isn't quite right.  Try this:

    insert into sales_copy(stor_id,ord_num,ord_date,qty,payterms,title_id)

    select stor_id, ord_num, ord_date, qty, payterms, title_id from sales

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • That worked, but didn't work for the pubs.authors and it worked when i created a table of my own (testing with 2 fields).

    Thanks all hope i stop my doubts for 2day...catch you all tomorrow.

     


    Kindest Regards,

    Arunkumar

    Reputation is what other people know about you. Honor is what you know about yourself."--

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply