Scripting when your sysdepends table is damaged
The situation
You need to script your database, but you know that your sysdepends table has become corrupted. This means that you'll have to work out the order in which you should present your object scripts to SQL Server so that dependencies are preserved. If you present them in the wrong order, they are likely to fail.
Key challenges
- Accurately ordering object scripts to preserve dependencies without using sysdepends.
- Reducing the time-overhead of a manual process.
How we can solve it
- Use SQL Packager to package the damaged database into a .NET executable.
- Select all the objects and data to be packaged.
- Preview the SQL code that will be used to create the schema and data.
The script will create the objects in the correct order. - Generate the package, using compression if required.
- Run the package on the destination server.
You can overwrite the damaged database, or you can create the database with a new name.
Alternatively, you could use SQL Compare to compare the damaged database with an empty database. You then generate a script to populate the empty database.
To learn more, take a look at our worked example.
Benefits of our solution
- SQL Packager™ can be run on the database while it is live, so there is no impact on users.
- Compressing the package reduces storage, transfer, and upload times.
- The package can be used again, if required.
Technical papers
- A simple solution to scripting when sysdepends is damaged
Online help
- SQL Packager: Packaging a database as a .NET executable

