Wednesday, March 28, 2012

model databases

Hi,

When i create a new table in Model database how can i automatically create table in other user databeses. Thanks for your answers

FYI, any object you create in the model databas will be automatically created in any user database you create in the future. So say, you create a table named Table1 in your model database, there will be a table named Table1 in all the user databases you create after that|||

The model database is the mold for future databases that are created. There is no mechanism in place to have other databases "inherit" the structures that are put into model after the database is created.

You would want to either A. Run the create script yourself in existing databases or B. Write a tool to cursor through all databases (possibly using sp_MSforeachdb, which is undocumented, but you can find an abundence of info on the web) and create the objects like that.

I would build something in a UI tool that logs your actions personally, as you should need to do this in dev, test, preprod, and/or prod at some time.

No comments:

Post a Comment