0

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

poolski
  • 124
  • 1
  • 3
  • 10

1 Answers1

1

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.

the-wabbit
  • 40,737
  • 13
  • 111
  • 174