Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 dba.stackexchange.com –  the-wabbit Jul 24 '12 at 8:51
    
Ah, I was unaware of dba.stackexchange.com –  poolski Jul 24 '12 at 9:05

1 Answer 1

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
      NORECOVERY;

and

USE AdventureWorks2012;
DROP USER AbolrousHazem;
GO

scripted through something like sqlcmd fit your need.

share|improve this answer

Your Answer

 
discard

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.