|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Tuesday, November 20, 2012 6:45 PM
Points: 398,
Visits: 2,405
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Today @ 1:15 AM
Points: 2,
Visits: 131
|
|
| Tried this script on SQL 2008, added a few columns and it worked like a charm. We will be saving a lot of time.:D
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Tuesday, November 20, 2012 6:45 PM
Points: 398,
Visits: 2,405
|
|
I'm glad it worked for sql version 2008. The only difference is the schema of the tables in sql 2000, 2005 and 2008 :)
"-=Still Learning=-"
Lester Policarpio
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Today @ 1:15 AM
Points: 2,
Visits: 131
|
|
We braught in the following on a few parts to ensure that we limit the possiblilty duplicates of the .mdf, .ndf and .ldf physical names and database names are not used.
Have you considered something like that?
We have quite a few environments and this helped to set them apart.
DECLARE @RestoreFrom varchar(20) SET @RestoreFrom = '_ServerName'
SET @restoredb = 'RESTORE DATABASE '+(select top 1 DatabaseName+@RestoreFrom from header_lester)
UPDATE migration_lester SET physicalname = left(Physicalname,charindex('.',Physicalname)-1)+ @RestoreFrom + Right(Physicalname,4)
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, January 04, 2013 7:24 AM
Points: 2,
Visits: 17
|
|
Edited the listing of the path for the location of the .bak files to use
SET @pathension = 'dir /OD /s /b '+@Path+'*.'+@Extension
Allowing for all .bak files in subdirectories and a shorter directory listing format. Just easier when all my .bak files were sitting in their own folders :)
Also had to remove the +@path in front of +@migrate in the 'Restoreheaderonly' statement as I was getting multiple '///' when the .bak file location was on the network.
Currently using it to restore 37 databases though, so it works like a charm!
Good job...
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Tuesday, November 20, 2012 6:45 PM
Points: 398,
Visits: 2,405
|
|
Glad it works
"-=Still Learning=-"
Lester Policarpio
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, November 12, 2009 7:08 AM
Points: 1,
Visits: 12
|
|
I have a problem with running this script, it returns this error message: -------------------------------------------------------- Msg 3201, Level 16, State 2, Line 1 Cannot open backup device 'C:\folder\abase1.bak'. Operating system error 2(The system cannot find the file specified.). Msg 3013, Level 16, State 1, Line 1 RESTORE HEADERONLY is terminating abnormally. ---------------------------------------------------------
I know it can't find abase1.bak because the real physical filename is database1.bak. Please, I'm not very good with SQL but I do have 150+ databases i want to import into MS SQL. Can anyone tell me where i need to look in the script to fix this up?
Thanks in advance for all helpful hints / solutions.
|
|
|
|