Scripting table population | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Scripting table population

Group, Is there any way that I can script the population of the tables in my db instead of having to import/export from one db to another? Jim James E Mace Flying Ace Software Solutions
From database to database you can do a direct insert.. select, such as INSERT INTO db1.dbo.table1 SELECT * FROM db2.dbo.table2 If you want a reusable script with a standard set of re-usable insert statements in it, you can generate these from the source tables by dynamically creating some insert statements along the lines of SELECT ‘INSERT INTO TABLE (cols) VALUES ( ‘ + column1 + ‘,’ + column2 + ‘)’
from table1 etc I think this is what you require?! Tom Pullen
DBA, Oxfam GB
Thanks for the statements, but I have 138 tables to repopulate. I try to import/export, but it would never populate all my tables (~40% unpopulated). Jim James E Mace Flying Ace Software Solutions
Why not use DTS with selection of tables? Satya SKJ
This posting is provided “AS IS” with no rights for the sake of knowledge sharing.
If import/export is failing at some point, it must be for a reason. do you get an error message? Also if you want the entire database backup/restore is much easier.
Tom Pullen
DBA, Oxfam GB