Page 1 of 1

Restore SQL Database

Posted: Thu Feb 14, 2008 8:38 am
by puckkk
Ok, 5 hours of testing and cannot find a solution.
I need to restore a sql 2005 sp2 database in my installation. But I cannot do it in any way cause I always receive acces denied from SQL (I'm using Vista).
I tried to use replace with move in program files $TARGETDIR$ but of course vista cannot do it without using administrators. So I thought the best way was:

RESTORE DATABASE [F24Manager]
FROM DISK = 'c:\\Programmi\\Hencos\\F24Manager\\F24Manager.bak'
WITH REPLACE,
MOVE 'F24Manager' TO
'C:\\Users\\enrico.SISTCONT.000\\AppData\\Roaming\\Hencos\\F24Manager\\F24Manager.mdf',
MOVE 'F24Manager_log' TO
'C:\\Users\\enrico.SISTCONT.000\\AppData\\Roaming\\Hencos\\F24Manager\\F24Manager.ldf'

(in IA I ofcourse use variables for files, but now I'm testing it directly on SQL studio management).
Error message is: acces denied. SQL server isn't able to write to %appdata% dir!. So, where my database could be store!? Where do u usually store sql database in your app? Do I have to restore in the default mssql data directory ? (programs\\...\\mssql\\data)? In that case, how could I retrieve sql default data dir from registry? Thanx in advance.