2010-09-18 12 views
8
BACKUP DATABASE <myDataBaseName> TO DISK = 'C:\PathtoBackup\FileName.bak' 

questa query è lavorato per un database che viene creato nella gui di SQLServer Express Editionquery per il backup di un database in un altro luogo nel file system

Ho attaccato la mia base di dati che è fisicamente a unità D (D: \ testing.mdf) a SQLServer utilizzando la GUI in SQlServer Mgmt Studio. Dopo il collegamento, SSMS visualizza il nome del database come "D: \ testing.mdf" in Esplora oggetti anziché in testing. SELECT DB_NAME() AS DatabaseName.

Questa query risultati della stessa che "D: \ testing.mdf"

La sopra citata interrogazione BACKUP non viene lavorato per più tardi

BACKUP DATABASE testing TO DISK = 'C:\PathtoBackup\testing.bak' 

ha dimostrato il seguente errore

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 

Ho provato in questo modo

BACKUP DATABASE D:\testing.mdf TO DISK = 'C:\PathtoBackup\testing.bak' 

il seguente errore è stato dimostrato

Msg 102, Level 15, State 1, Line 1 
Incorrect syntax near 'D'. 

Cosa devo fare per backup di file che è in posizione diversa nel filesystem

+3

fa questo percorso 'C: \ PathtoBackup' esiste fisicamente sul tuo SQL Server quando esegui il comando BACKUP ?? Inoltre: il messaggio di errore indica che il database "TESTING" non fa realmente parte di SQL Server - non è stato collegato/ripristinato correttamente in tale istanza di SQL Server. Riesci a vedere il database di TEST nel tuo Mgmt Studio e puoi interrogarlo ?? –

+0

Sì, C: \ PathtoBackup esiste.E Ho collegato il database "testing" a SQLserver utilizzando la GUI in SQlServer Mgmt Studio. Dopo aver allegato SSMS, il nome del database viene visualizzato come "D: \ testing.mdf" in Object Explorer anziché in testing. SELECT DB_NAME() AS DatabaseName'. Questa query risulta identica a "D: \ testing.mdf" –

+1

Se il database è chiamato d: \ testing.mdf, quindi racchiuderlo tra parentesi [parentesi]. Se si chiama Test, quindi utilizzare il nome del database anziché il nome del file. – u07ch

risposta

12

Grazie @u07ch

ho ottenuto it.Finally ho ottenuto il risultato desiderato dal tuo suggerimento.

BACKUP DATABASE [D:\testing.mdf] TO disk = 'C:\PathToBackup\BackupFileName.bak' 

Il file di backup è stato creato correttamente.

0

Path può essere qualsiasi posizione sul vostro sistema in modo seguente query sta lavorando bene per prendere il backup di un database: backup del database empdb su disco = 'c: /empdb.bak'

Problemi correlati