I have a SQL Server 2005 database, that I would like to be able to recreate at a moment\'s notice. I want to be able to point to my database and generate a complete set of s
What I always do is let MS SQL Management Studio create the script to rebuild database und empty tables. Then I use another script to generate a ms-dos batch file to export/import the data via "bcp". See sql below.
/* this is used to export */
use databaseXXX
select ('bcp databaseXXX..' + name + ' OUT ' + name + ' /eErrors.txt /b100 /n /Usa /Ppwd /Sserver') as bcp
from
sysobjects
where
type = 'U'
order by
[name]
/* this is used to import */
use databaseXXX
select ('bcp databaseXXX..' + name + ' IN ' + name + ' /E /eErrors.txt /b100 /n /Usa /Ppwd /Sserver') as bcp
from
sysobjects
where
type = 'U'
order by
[name]
Works for me everytime and is quick. If you save the table generation script in a file you can put this also into a batch file via sqlcmd command.