Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TSQL syntax to restore .bak to new db

Tags:

tsql

I need to automate the creation of a duplicate db from the .bak of my production db. I've done the operation plenty of times via the GUI but when executing from the commandline I'm a little confused by the various switches, in particular, the filenames and being sure ownership is correctly replicated.

Just looking for the TSQL syntax for RESTORE that accomplishes that.

like image 906
justSteve Avatar asked Dec 17 '22 01:12

justSteve


1 Answers

Assuming you're using SQL Server 2005 or 2008, the simplest way is to use the "Script" button at the top of the restore database dialog in SQL Server Management Studio. This will automatically create a T-SQL script with all the options/settings configured in the way you've filled in the dialog.

like image 132
Daniel Renshaw Avatar answered Dec 21 '22 23:12

Daniel Renshaw