Quick-gun Morgan
Quick-gun Morgan

Reputation: 338

How to export a Table's schema to another Database?

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

Answers (2)

Elias
Elias

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

enter image description here

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.

enter image description here

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.

enter image description here

Then Just Generate it in your desired format and make sure you're pointing them all to the correct database!

Upvotes: 3

jpw
jpw

Reputation: 44921

Using SQL Server Management Studio you can right-click on the database in the Object Explorer and choose Tasks/Generate Scriptsand follow the instructions in the wizard.

Upvotes: 2

Related Questions