Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We're having to do an emergency migration of all of our MSSQL databases from a dying box to a new shiny instance of SQL2008. Unfortunately, we're having to do it by restoring from nightly backups (.bak files).

Is there a way of:

  • Automating the restore of a batch of files so as to go:
    • DatabaseName.bak >[restore to]> DatabaseName
  • Automating the removal of a specific user from the DB's security>users list?

Yell if you need more information

share|improve this question
Is it the same user or users across all databases? – Kev Jul 24 '12 at 1:09
Kev, yes, it is. The permissions are the same across most DBs too – poolski Jul 24 '12 at 8:14
consider posting database-related questions to – the-wabbit Jul 24 '12 at 8:51
Ah, I was unaware of – poolski Jul 24 '12 at 9:05
up vote 1 down vote accepted

You probably would see a couple of T-SQL statements like

RESTORE DATABASE AdventureWorks2012
   FROM DISK = 'Z:\SQLServerBackups\AdventureWorks2012.bak'
   WITH FILE = 6


USE AdventureWorks2012;
DROP USER AbolrousHazem;

scripted through something like sqlcmd fit your need.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.