0

On SQL Server 2012, we have been using the [model] DB so that we can easily create project DBs with all the objects (schemas, tables, stored procedures, user-defined types) already set up with a CREATE DATABASE statement.

However, if we want to clear all of this out and start over, is there an easy way to do this? Naturally we can't DROP it.

1

2 Answers 2

0

You can do a backup and restore of model database from another server that is the same version. If you have another SQL 2012 server available with an untouched model database, then just back it up and restore it.

You'll need to double check that all of the settings are exactly what you want because TempDB will be created from the new model database on next restart. This could cause problems if collation or other settings are different.

1
  • Both answers were helpful but this was the easiest - thanks!
    – Ddddan
    Commented Jan 24, 2018 at 14:07
0

If you took a backup prior to adding objects to it you can just restore the backup. If you do not have a backup to restore from, you could take a backup of one that is empty and use that as your restore point.

Alternatively - you could delete all of the objects that you created within it. Check out some of the answers to this question for ideas around scripting this.

Failing all of the above, you might have to rebuild your system databases.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.