Reputation: 338
I have 10 tables in my database. Out of this I want to generate 5 tables with same structure and dependencies in a different database. I don't need to copy the data inside these tables, just the schema of tables. How do I do this? I don't want to manually copy the code but to generate files to export.
Upvotes: 0
Views: 132
Reputation: 2632
If you are copying from database(Schema) in SQL Server
to another, then what you can do is use the Tasks>Generate Scripts
From here you press the Select Specific Database Objects
and select the tables in the tables
section that you want to carry to your new database.
Then go to the Set Scripting Options
Menu, and press the advanced
button at the top right of that menu. Another menu will pop up with options. Based on what you said the default (following) options should work.
Then Just Generate it in your desired format and make sure you're pointing them all to the correct database!
Upvotes: 3
Reputation: 44921
Using SQL Server Management Studio you can right-click on the database in the Object Explorer and choose Tasks/Generate Scripts
and follow the instructions in the wizard.
Upvotes: 2