Really tired of having to google this and piece it together every time I want it, so I'm posting it here.
alter database DbName
set single_user
with rollback immediate
go
restore database DbName
from disk = 'path/to/backup.bak'
with file = 1, replace
Notables:
- Works best to run against the master database.
- The file = 1 part may need to be changed if there are multiple backups in the file and the one you want isn't the first one.
Comments !