JohnSThomas
JohnSThomas

Reputation: 11

How to copy structure of all tables to a new empty database?

How do I copy the structure only (i.e., empty, no user data) of all tables, views, and indices from one SQL-Server database to new (empty) database?

(If anyone remembers dBase, this was done with "copy struct" for each table. I know also that this could be done by reverse-engineering the structure of the database into SQL statements using a tool like ERWin, but I don't have that either.)

I'm working in a very bureaucratic (maybe even paranoid) client site, in which I can only create temp tables, and only read from the regular tables. But it's really important that I be able to insert and update in a "safe" area.

Upvotes: 1

Views: 595

Answers (2)

xmojmr
xmojmr

Reputation: 8145

Microsoft's SQL Server supports this scenario through partially abstract tools that can work with the database model, visualize it, edit it, transfer the model from one place to another and even compute differences between models and this way create database schema upgrade script.

The part that I have memorized is that those models are stored in big XML files called *.dacpac and there is a schema compare button available if I open *.sqlproj project in Visual Studio

This is whole architectural concept, more abstract and different from dBase, and you can start learning more about it e.g. at

Microsoft SQL Server - Data-tier applications

(Or try Google: "dacpac deployment")

Upvotes: 0

sqlab
sqlab

Reputation: 6436

You can generate scripts to generate a cloned test area for your database Documenting and Scripting Databases

Upvotes: 1

Related Questions