|
Duplicating Table Structure
|
|
Let's say you have a table called authors. You need to to duplicate the structure of this table into another table. How will you do it?? Here is the query that you can use to achieve the same.
The authors table that we use here is available in the pubs database in SQL Server. The above statement copies over the structure of the table into another table (called newAuthors). The WHERE 1=0 clause ensures that only the structure is copied over and no data. Note that we said only structure. The new table that is created, will not have any constraints or indexes defined in the old table carried over. You need to create these manually. |
| Home |