• The easiest way to do it is to write a detach/attach or backup/restore script for all databases and use it. That is what our DBA is doing. She spent not so much time for codding these scripts but it is easy to use.

    To write the scripts for 40 databases is easy this way:

    write a select statement that will generate the scripts.

    Read RESTORE (T-SQL) article in BOL. It contains the example for database copy from Production to Development:

    Step 1

    BACKUP DATABASE AdventureWorks

    TO DISK = 'C:\AdventureWorks.bak'

    Step 2

    RESTORE FILELISTONLY

    FROM DISK = 'C:\AdventureWorks.bak'

    Step 3

    RESTORE DATABASE TestDB

    FROM DISK = 'C:\AdventureWorks.bak'

    WITH MOVE 'AdventureWorks_Data' TO 'C:\testdb.mdf',

    MOVE 'AdventureWorks_Log' TO 'C:\testdb.ldf'

    GO

    The following Select statement will produce the scripts for backing up all databases on your server (step 1)

    select 'BACKUP DATABASE ' + name +' TO DISK = '

    +'''' + 'C:\' + name + '.bak' + ''''

    from sys.databases

    Use something similar for steps 2 and 3. Four single quotes in Select will give you one single quote in the result where you have to have single quotes around file names.

    Regards,Yelena Varsha