[dba-SQLServer] add timestamp column to all tables

Arthur Fuller fuller.artful at gmail.com
Thu Jan 19 10:35:38 CST 2012


Somewhere, on some eZine (can't remember which, perhaps TechRepublic or
Simple-Talk) I wrote a piece about modifying modeldb, the idea being based
on the fact that every new db is created based on modeldb. This, IMO, is a
very powerful and exceedingly lazy way to accomplish a lot in a little
time. I have investigated this avenue at some length and have come up with
this approach:

1. Copy modeldb to a new db, naming it appropriately (see next step).
2. Depending on our niche(s), we all have several models. One might be what
we at Artful call YAFOES (yet another  f***ing Order Entry System), which
involves Customers, Orders, OrderDetails, and Products. Another might be
YACAS (yet another accounting system), which involves a Chart of Accounts,
four quadrants, and so on.
3. Copy the virgin modeldb and give it a name such as VirginModelDB.
4. For each of your models, import the tables and sprocs and views and udfs
that every such app will typically need.
5. When you need to create a new db, rename modeldb and rename
ModelYafoesDB to modeldb, then create your new database.

Result: a new db containing lots of what you need, built in. The last step
is to restore the original modeldb to said name -- unless, of course, you
specialize in a particular niche, in which case the customized modeldb will
serve as your starting ground for each new project. However, you need also
be aware of updates to SQL Server, which might potentially wipe out your
changes to modeldb. That's why you should always create VirginModelDB, and
after an upate to SQL, copy the new modeldb to VirginModelDB, and you're
ready to go. Lock and load, as it were.

This approach has worked very well for me for the past few years, when it
first occurred to me. I copied modeldb to a new db called VirginModeldb,
then rolled into modeldb the tables Customers, Orders, OrderDetails and
Products, plus some queries and sprocs and views; finally I created a new
db based on the customized model and Lo and Behold! Everything carried into
my new baby.

I don't take entire credit for this notion. It was inspired in the first
place by a chapter of a book on SQL by my good friend Dejan Sunderic. You
can find his books on Amazon. I highly recommend them.

-- 
Arthur
Cell: 647.710.1314

Prediction is difficult, especially of the future.
  -- Niels Bohr


More information about the dba-SQLServer mailing list