Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Create table clone

Author  Topic 

lebedev
Posting Yak Master

126 Posts

Posted - 2002-07-18 : 18:45:25
Is there a way to create a clone of the given table. In other words, given a table name, I want to create another table (static table, not a table variable) with a different name, but the same schema.
I need to be able to do this in a programmable way using SQL, or T-SQL.
thanks.

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-07-18 : 19:20:55
SELECT * INTO Table2 FROM Table1

Creates a new Table (Table2) from Table1. Only structure and data; indexes and constraints are NOT created.

Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2002-07-18 : 19:21:30
Like this: (This works on PUBS)
select a.*

into authors2

from authors a

Michael

<Yoda>Use the Search page you must. Find the answer you will.
Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2002-07-18 : 22:07:46
Sniped by 35 second? wow

Michael

<Yoda>Use the Search page you must. Find the answer you will.
Go to Top of Page

sandesh_moghe
Constraint Violating Yak Guru

310 Posts

Posted - 2002-07-19 : 03:34:38
One way is there to clone....
Follow the following steps

1. Single click on the table which you want to clone (In Enterprise Manager)

2. Press Ctrl+ C

3. Press Alt+T+Q (This will open Query Analyser)

4. Press Ctrl+V in QA

5. Press Ctrl+H, Type "TableName" in Find Text box. and "New TableName" in Replace with Text box.

6. Press Alt+A

7. Press Ctrl+E

Yes, Thats it..............isnt it simpler way to clone the table. If you practice thrice a day, the you will be master in cloning.....

All The Best.


---------------------------
Sandesh - The Messanger
Go to Top of Page
   

- Advertisement -