March 3, 2016 at 7:33 am
Good day,
I am wondering what would be the easiest way to recreate an existing database schema (sprocs, tables, constraints, etc..) without the data.
In MSSQL, I know you can use the Generate Scripts in Task but this doesn't create a runnable script, you still need to order the execution manually since some tables might reference to other tables that aren't created yet.
What's the best practice? (Knowing that this is a large database...)
Regards,
Shany Grimard
March 3, 2016 at 7:36 am
Best practice, be efficient. I know it sounds bad, but use a tool. This is a problem that doesn't lend itself to using your own time and effort to build as there is complexity here.
The Generate scripts, if you build one script, should be runnable. Generate all objects and they should be ordered properly. If there a bugs in this process, I'd submit them to connect.microsoft.comhttp://connect.microsoft.com/.
If you want more options, filtering, etc., a tool like SQL Comparehttps://www.red-gate.com/products/sql-development/sql-compare/ does this very well and is worth the cost in time savings.
Disclosure: I work for Redgate.
March 3, 2016 at 10:31 am
Red-Gate +1
March 3, 2016 at 11:01 am
sgrimard (3/3/2016)
Good day,I am wondering what would be the easiest way to recreate an existing database schema (sprocs, tables, constraints, etc..) without the data.
In MSSQL, I know you can use the Generate Scripts in Task but this doesn't create a runnable script, you still need to order the execution manually since some tables might reference to other tables that aren't created yet.
What's the best practice? (Knowing that this is a large database...)
Regards,
Shany Grimard
if we are talking schema only/no data, the easier method is to generate the tables without the foreign key constraints, and generate the foreign keys separately. you can append them to the same file, but having all constraints added at the end solves the hierarchy order.
Lowell
March 3, 2016 at 11:27 am
If all you want is the structure, here's another vote for using the DACPAC. However, I'm with Steve (on multiple levels, I work with him), that if you need to do this regularly, the best way is with Redgate SQL Compare. It's all about the ability to automate and control what gets moved, when and how. If you're doing it a lot, we have the right tools for the job.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply