BACKUP DATABASE <myDataBaseName> TO DISK = 'C:\PathtoBackup\FileName.bak'
this query is worked for a database which is created in the gui of SQLServer express edition
I have attached my database which is physically at D drive(D:\testing.mdf) to SQLServer using GUI in SQlServer Mgmt Studio.After attaching, SSMS displays the database name as "D:\testing.mdf" in Object explorer rather than testing.
SELECT DB_NAME() AS DatabaseName
.
This query results the same that "D:\testing.mdf"
The above mentioned BACKUP query is not worked for later
BACKUP DATABASE testing TO DISK = 'C:\PathtoBackup\testing.bak'
the following error has been shown
Msg 911, Level 16, State 11, Line 1
Could not locate entry in sysdatabases for database 'testing'. No entry found with that name. Make sure that the name is entered correctly.
Msg 3013, Level 16, State 1, Line 1
BACKUP DATABASE is terminating abnormally
I have tried like this
BACKUP DATABASE D:\testing.mdf TO DISK = 'C:\PathtoBackup\testing.bak'
the following error has been shown
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'D'.
What should I do to backup that file which is at different location in filesystem
Thank you @u07ch
I got it.Finally I got the desired result by your tip.
BACKUP DATABASE [D:\testing.mdf] TO disk = 'C:\PathToBackup\BackupFileName.bak'
The backup file has created successfully.
Path can be any location on your system so following query is working fine to take backup of a database:
backup database empdb to disk = 'c:/empdb.bak'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With