HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlModerate

SQL Server Database "default" tables

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
tablessqldatabasedefaultserver

Problem

When I add a new database to our dev server (using SSMS), it automatically creates 5 tables.

These are copies of application tables that already exist in another database.

I assume this is some recent SQL Server feature I don't know about where tables can be marked as 'common' or some such, and so get added automatically to new databases.

But how can I stop it happening?

For the avoidance of confusion, this database is not scripted, it is created directly from the SSMS GUI (right-click Databases > New Database)

(moved from StackOverflow)

Solution

This happens (based on the discussion in comments) because the tables exist in the model system database. As per the documentation (my emphasis):


If you modify the model database, all databases created afterward will
inherit those changes. For example, you could set permissions or
database options, or add objects such as tables, functions, or stored
procedures. File properties of the model database are an exception,
and are ignored except the initial size of the data file.

As a solution, dropping the tables from model will stop this phenomenon.

Context

StackExchange Database Administrators Q#149000, answer score: 15

Revisions (0)

No revisions yet.