Editorials

Using the Model Database

The model database is a standard database created for every instance of SQL Server, just like Master, MSDB and TempDB. Unlike the other system databases, model is not used frequently. In fact, it is only used when a new database is created.

When you create a new database, it clones the model database. So, as you can see, every user defined procedure, function, type, table, etc. will be copied into your new database.

I have a few functions I use for grouping and filtering time. I also have a Tally table, since they are extremely useful for many different kinds of query optimizations. A third thing I have is a generic pivot table I may use for optimizing pivot queries.

What kinds of things do you put in your Model database so that they are available in new databases you create on your server? Share you best ideas here online, or drop an email to btaylor@sswug.org.

Cheers,

Ben