May 9, 2009 at 12:45 pm
Restore a DB from SSMS always works fine, but when I do it inside a program in order to do this task more quick to do, or just to give this task to a user, not always works, with small DB's it works fine, but with a much larger DB, it never finishes.
Or rather the program finishes as if the task were completed, but if you look at the DB in the SSMS it shows as (Restoring...)
the T-SQL I am sending the server is the following:
RESTORE DATABASE TPR FROM DISK = 'C:\RespaldosSQL\TPR_20090506-1.BAK' WITH FILE = 1, MOVE 'TPR' TO 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\TPR.MDF', MOVE 'TPR_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\TPR_Log.LDF', REPLACE
What did I miss ?
Thanks
Andres
May 9, 2009 at 4:30 pm
just checking the basics...the connection string your program is using is connecting to master database and not the database you are trying to restore right? if it connects to teh same db you are trying to restore, i'd expect it to fail like that...could that be it?
Lowell
May 9, 2009 at 4:38 pm
just checking the basics...the connection string your program is using is connecting to master database and not the database you are trying to restore right? if it connects to teh same db you are trying to restore, i'd expect it to fail like that...could that be it?
edit...doh you are missing the RECOVERY flag, right? otherwise it would be waiting for additional logs:
RESTORE DATABASE TPR
FROM DISK = 'C:\RespaldosSQL\TPR_20090506-1.BAK' WITH FILE = 1 ,RECOVERY,
MOVE 'TPR' TO 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\TPR.MDF',
MOVE 'TPR_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\TPR_Log.LDF',
REPLACE
Lowell
May 9, 2009 at 8:14 pm
Lowel:
Thanks for your rapid response, I tried the WITH RECOVERY option, and it don't made any difference, and the help says RECOVERY option is the default, so i guess is the same with and without it.
I tried the same query in SSMS and it worked perfectly, but if i try it from my program, it stills does the same thing, it puts the Restoring... tag to the DB.
Andres
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply