Create Duplicate SQL Database for Testing

前端 未结 7 1536
栀梦
栀梦 2021-02-01 03:07

I have created a database on SQL server and a front end user application in winforms c#. It\'s up and running and working fine, but I\'ve now been asked to set up a test version

7条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-01 03:33

    using MS SQLServer 2012, you need to perform 3 basic steps

    first, generate .sql file containing only the structure of the source DB

    => right click on the source DB and then Tasks then Generate Scripts => follow the wizard and u can save the .sql file locally

    Second, replace in .sql file the source db with the destination one

    => right click on the destination file, open the .sql file and press New Query and Ctrl-H or (edit - find and replace - Quack replace)

    finally, populate with data

    => right click on the detination DB, then Tasks and then Import Data => Data source drop dow set to ".net framework data procider for sql server" + set connection string text field under DATA ex: Data Source=Mehdi\SQLEXPRESS;Initial Catalog=db_test;User ID=sa;Password=sqlrpwrd15
    => Same thing to do with the destination => check the table you want to transfer or check box besides "source :....." to check all of them

    you are done.

提交回复
热议问题