I'm looking for a simple script that I can use to overwrite one database with another one. We have a master db with master schema and data and every so often a developer wants to blow away his messed up db with a complete overwrite from the master. I currently accomplish this with SQL Server Studio and the GUI controls but I want something similar to what we use when restoring from a backup file (just without the backup file step):
RESTORE DATABASE [SlaveDB]
FROM DISK = N'E:\Backup\MasterDB.bak'
WITH FILE = 1,
MOVE N'SlaveDB_Data' TO N'E:\Data\SlaveDB_Data.mdf',
MOVE N'SlaveDB_Log' TO N'E:\Log\SlaveDB_Log.ldf',
NOUNLOAD,
STATS = 10
GO
What's the syntax for getting the db from another db instead of a backup file?