Method #1: [the better option]
- get the creation table information of the table to be duplicated
- change the table name
- execute the script
Method #2: this will remove the index definitions of the table though. Use:
CREATE TABLE <newtable> SELECT * FROM <oldtable> WHERE 1 = 0;
the where clause just says you are ONLY copying the structure and not the data.
Method #3: Copy to and from another database
- Copy the table to another database[#2]
- Rename the table on the other database[#2]
- Copy back to the source database[#1]
MS-SQL version of Method 2:
ReplyDeleteselect *
into [new table]
from [old table]
where 1 = 0