Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Automatically Restore Backup Files for SQL 2005 Expand / Collapse
Author
Message
Posted Friday, December 12, 2008 5:58 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, March 06, 2014 2:38 AM
Points: 398, Visits: 2,423
Comments posted to this topic are about the item Automatically Restore Backup Files for SQL 2005

"-=Still Learning=-"

Lester Policarpio

Post #619000
Posted Monday, February 02, 2009 2:49 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, March 27, 2014 6:27 AM
Points: 2, Visits: 162
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
Post #647877
Posted Monday, February 02, 2009 6:59 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, March 06, 2014 2:38 AM
Points: 398, Visits: 2,423
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

Post #648520
Posted Tuesday, February 03, 2009 3:30 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, March 27, 2014 6:27 AM
Points: 2, Visits: 162
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)
Post #648680
Posted Thursday, May 28, 2009 7:38 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum 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...
Post #725039
Posted Monday, September 28, 2009 8:32 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, March 06, 2014 2:38 AM
Points: 398, Visits: 2,423
Glad it works

"-=Still Learning=-"

Lester Policarpio

Post #794886
Posted Tuesday, November 10, 2009 3:56 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum 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.
Post #816391
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse