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 |
|
noyellatmonkeys
Starting Member
15 Posts |
Posted - 2009-11-22 : 23:31:49
|
| hello,I need to duplicate the tables from one database to another. I do not need the data. i use sql server management studio express. I used the import/export wizard and copied the tables over (data and all, i figured i would just delete the data afterwards). But although the tables were there, it was missing the column attributes like that id is identity and to auto increment or the default values i have for some of the columns. Any suggestions how i can get the tables over with the column attributes? whether the data copies over is irrevalent.Thank you! |
|
|
lionofdezert
Aged Yak Warrior
885 Posts |
Posted - 2009-11-23 : 02:12:45
|
| Generate script for objects (Tables,Views,Functions,Sps and Schema) from your source database and execute it in target database. |
 |
|
|
kbhere
Yak Posting Veteran
58 Posts |
Posted - 2009-11-23 : 06:26:29
|
| SELECT INTO destinationdatabase.schemaname.tablename FROM sourcedatabase.schemaname.tablenameThis is the general syntax for copying table from one database to another.. but this will copy the table along with the data..Since you have enquired for copying tables i have posted this.. Wishes,Balaji.K |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-11-23 : 07:10:06
|
quote: Originally posted by kbhere SELECT INTO destinationdatabase.schemaname.tablename FROM sourcedatabase.schemaname.tablenameThis is the general syntax for copying table from one database to another.. but this will copy the table along with the data..Since you have enquired for copying tables i have posted this.. Wishes,Balaji.K
It will not copy the indices. Better way is generating sql script and running it on the target databaseMadhivananFailing to plan is Planning to fail |
 |
|
|
NeilG
Aged Yak Warrior
530 Posts |
Posted - 2009-11-23 : 08:07:34
|
| I'd generate the scripts through SSMS and not a SELECT * INTO statement |
 |
|
|
noyellatmonkeys
Starting Member
15 Posts |
Posted - 2009-11-23 : 12:19:52
|
| Thank you everybody on your advice and time. |
 |
|
|
|
|
|