December 12, 2008 at 5:58 pm
Comments posted to this topic are about the item Automatically Restore Backup Files for SQL 2005
"-=Still Learning=-"
Lester Policarpio
February 2, 2009 at 2:49 am
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
February 2, 2009 at 6:59 pm
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
February 3, 2009 at 3:30 am
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)
May 28, 2009 at 7:38 am
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...
September 28, 2009 at 8:32 pm
Glad it works 🙂
"-=Still Learning=-"
Lester Policarpio
November 10, 2009 at 3:56 am
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.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply