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.
| Author |
Topic |
|
pug2694328
Posting Yak Master
166 Posts |
Posted - 2006-05-18 : 09:00:07
|
| In DB2 it is possible to use an existing table as a model for a new empty table in a CREATE TABLE query. So you don't need to specify any of the table attributes, they are all pulled from the existing specified table 'model'.Is this possible in M$ SQL?Is it possible create an entire database using an existing DB as a model?Can someone provide an example query for each (if they exist). |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2006-05-18 : 09:04:47
|
| The closest analog that SQL Server has is SELECT...INTO:SELECT * INTO myNewTable FROM myTableThis will not copy indexes, constraints, keys and such, only the column definitions and the data.You can generate a script to create an entire database and all its objects. If you also need the data, you can make a full backup of the database and restore it to a new one, or create SQL scripts to insert the data you need. |
 |
|
|
pug2694328
Posting Yak Master
166 Posts |
Posted - 2006-05-18 : 09:12:59
|
| Thanks Robvolk! Explains why I couldn't find it in the doc. : )Yeah I'll write a script unless it's just a quickie one-off. |
 |
|
|
|
|
|