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
You want to copy one Database_Production to Database_Testing in the same server. I would take database_production database as an example. I tested it in my server successfully.
Firstly, backup the database Database_Production.
backup database Database_Production to disk='H:\test\Database_Production.bark';
Secondly, restore Database_Production and this could rename the database name to Database_Testing.
restore database Database_Testing from disk='H:\test\Database_Production.bark' WITH move 'Database_Production_Data' to 'H:\test\Database_Testing_Data.mdf', move 'Database_Production_log' to 'H:\test\Database_Testing_Data.ldf'; GO
Then the database Database_Production is copied to database Database_Testing. The MOVE statement causes the data and log file to be restored to the specified locations. You do not need to create database Database_Testing and the script would create it.