[dba-SQLServer] Scripting data transfers

Arthur Fuller fuller.artful at gmail.com
Sat Sep 3 10:44:56 CDT 2011


A little-appreciated feature of SQL Server is the model database. Its name
describes its function. Every database you create is based on model. All the
tables, all the rows, all the sprocs, all the UDFs, all the triggers are
copied from model to your new database.

I have played with this and I love this feature. Of course, I first copied
the vanilla model to a new database called Vanilla_Model, then I imported a
number of common tables (Customers, States, Provinces, etc.) into model and
finally created a new database. Lo and behold, everything I added to model
was automagically present in the new db.

If you don't want to take this approach, you can still generate scripts
including the insert statements. Open Management Studio, open the tables
list and right-click. If you do so on the Tables list, as opposed to a given
table, you can script them all at once, into individual files or one giant
file containing everything.

HTH,
Arthur

On Sat, Sep 3, 2011 at 11:19 AM, jwcolby <jwcolby at colbyconsulting.com>wrote:

> I am building scripts (stored procedures) to create tables from a template
> database into another database.
>
> I have data in these table that I need to script to be inserted into the
> resulting tables created in the first .  Is there generic syntax to do that
> or do I need to build a hard coded insert sql statement for each one?
>
>



More information about the dba-SQLServer mailing list