SHARE
TWEET

Untitled

a guest Jun 25th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {
  2.  conn = new ServerConnection
  3.            {
  4.                ConnectionString = @"Data Source =
  5.  (localdb)MSSQLLocalDb;Initial Catalog=master;Integrated Security=true",                
  6.             };
  7.  
  8.  
  9.         try
  10.         {
  11.             //Restore Full
  12.             srv = new Server(conn);
  13.             //lsrv = srv.LinkedServers[@"DEVSQLALPHA"]; need to figure out how to restore to linked server instead of local.
  14.             //srv.KillAllProcesses("G4TestNew");
  15.             var res = new Restore();
  16.             res.Database = "G4TestNew";
  17.             res.Action = RestoreActionType.Database;
  18.             filePath = @"\CABCSERVERDatabaseTempFull.bak";
  19.             res.Devices.AddDevice(filePath, DeviceType.File);
  20.             res.ReplaceDatabase = true;
  21.             res.NoRecovery = true;
  22.             var dataFile = new RelocateFile("G4Test", @"C:TBDG4Test.mdf");
  23.             var logFile = new RelocateFile("G4Test_log", @"C:TBDG4TestNew.ldf");
  24.  
  25.             res.RelocateFiles.Add(dataFile);
  26.             res.RelocateFiles.Add(logFile);
  27.  
  28.             res.SqlRestore(srv);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top