When I try to restore a database using a restore command with a local UNC path:
RESTORE DATABASE [dbname]
FROM DISK = N'\\PC91\D\backup.BAK' WITH FILE = 1,
MOVE N'test' TO N'\\PC91\D\dbname.MDF',
MOVE N'test_log' TO N'\\PC91\D\dbname_log.LDF',
NOUNLOAD, STATS = 10
I get an error:
Msg 3634, Level 16, State 1, Line 1
The operating system returned the error '5(Access is denied.)' while attempting 'CreateFileW' on '\PC91\D\dbname.MDF'.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
If I use a local drive letter instead, then it works:
RESTORE DATABASE [dbname]
FROM DISK = N'D:\backup.BAK' WITH FILE = 1,
MOVE N'test' TO N'D:\dbname.MDF',
MOVE N'test_log' TO N'D:\dbname_log.LDF',
NOUNLOAD, STATS = 10
This command also restores the database to same folder. So why is there an error when I specify the network path?
D
that points to the root ofD:
? Or did you mean to use the administrative share name for the drive (D$
)? Why do you want to use a UNC path for a local database? Why in the root (which can have certain restrictions and require elevation of privileges) instead of data/log folders?