Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Restore script not working


Restore script not working

Author
Message
Gazareth
Gazareth
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2867 Visits: 5345
Also, if that insert statement is commented out, you'll never enter the WHILE loop.
cor_perlee
cor_perlee
Grasshopper
Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)

Group: General Forum Members
Points: 20 Visits: 316
I feel really stupid Smile

I have been looking at it all day and never saw the insert statement commented out.

Thanks!!

There are some more problems now but I will look at it tomorrow,
Looks like the variable substitution is failing.


Thanks all so far!!

Msg 5105, Level 16, State 2, Line 102
A file activation error occurred. The physical file name '@data_file_path@restore_as@mdf_extension' may be incorrect. Diagnose and correct additional errors, and retry the operation.
Msg 3156, Level 16, State 3, Line 102
File 'U4S33_Data' cannot be restored to '@data_file_path@restore_as@mdf_extension'. Use WITH MOVE to identify a valid location for the file.
Msg 5105, Level 16, State 2, Line 102
A file activation error occurred. The physical file name '@data_file_1_path@restore_as@ndf_extension' may be incorrect. Diagnose and correct additional errors, and retry the operation.
Msg 3156, Level 16, State 3, Line 102
File 'U4S33_Data1' cannot be restored to '@data_file_1_path@restore_as@ndf_extension'. Use WITH MOVE to identify a valid location for the file.
Msg 5105, Level 16, State 2, Line 102
A file activation error occurred. The physical file name '@log_file_path@restore_as@ldf_extension' may be incorrect. Diagnose and correct additional errors, and retry the operation.
Msg 3156, Level 16, State 3, Line 102
File 'U4S33_Log' cannot be restored to '@log_file_path@restore_as@ldf_extension'. Use WITH MOVE to identify a valid location for the file.
Msg 3119, Level 16, State 1, Line 102
Problems were identified while planning for the RESTORE statement. Previous messages provide details.
Msg 3013, Level 16, State 1, Line 102
RESTORE DATABASE is terminating abnormally.

Gazareth
Gazareth
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2867 Visits: 5345
No worries, done it plenty of times myself Smile

Your set statements are just setting your paths to e.g. '@data_file_path@restore_as@mdf_extension'
Drop all the ' from them and you should be ok.
cor_perlee
cor_perlee
Grasshopper
Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)

Group: General Forum Members
Points: 20 Visits: 316
Indeed that does seem to solve the problem except for 1 thing:

Msg 8114, Level 16, State 12, Line 103
Error converting data type varchar to nvarchar.

it seems to be here:

RESTORE DATABASE @restore_as
FROM DISK = @full_backup_path WITH FILE = 1,
MOVE 'U4S33_Data' TO @data_file_full_path,
MOVE 'U4S33_Data1' TO @data_file_1_full_path,
MOVE 'U4S33_Log' TO @log_file_full_path


I tried setting @restore_as to NVARCHAR but that didn't work.

I then added these satements to the script

print @data_file_full_path
print @data_file_1_full_path
print @log_file_full_path


Results:

D:\Data\25000994.ndf
D:\Logs\25000994.ldf

The first SET statement is not shown.(.mdf file) So I think the problem is there.

Cheers,

Cor
cor_perlee
cor_perlee
Grasshopper
Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)

Group: General Forum Members
Points: 20 Visits: 316
It turned out there was a typo in the

SET @ndf_extension = '.ndf' statement.

everything works now

Thanks to all for your help!

Much appreciated!

Cheers,

Cor
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search