Frage

Ich würde mich nicht als Angst vor der Veränderung beschreiben - aber Angst vor neuen Technologien? Jawohl! Technologien von Betriebssystemen, Datenbankserver scheinen nur abgehört zu werden, ineffizient und rückwärts, je weiter sie „Fortschritt“

MSDE 2000 (was sie nennen könnte "SQL 2000 Express" in der heutigen Welt)

BACKUP [MyDatabase] TO FILE 'c:\backups\mybackup.backup'

SQL 2008 EXPRESS

Warten Sie auf! Es ist ein ‚Benutzerinstanz‘ - um es wieder müssen wir es auf eine Serverinstanz
anhängen Warten Sie auf! So bringen wir es brauchen SQL Management Studio Express (78MB Download)
Warten Sie auf! Wenn wir dich ein, um unsere \ SQLEXPRESS Serverinstanz und versuchen, unsere Datenbank zu befestigen es gibt uns einen Fehler das sieht buchstäblich wie ein Fehler in unserem Homebrew Entwickler Projekt:.

TITEL: Microsoft SQL Server Management Studio

Kann nicht zeigen Dialog angefordert werden.

------------------------------ ZUSÄTZLICHE INFORMATIONEN:

Parametername: nColIndex Istwert war -1. (Microsoft.SqlServer.GridControl)

Kann jemand erklären, wie die Sicherung eines Benutzer Instanz einer SQL Server 2008 Express-Datenbank in T-SQL-Code?

(sorry, wenn das kommt ganz wie eine Flamme bei ummmm, Microsoft -. Ich bin eigentlich ein großer Fan von ihnen nur wirklich wütend über Dinge wie diese mir bitte nicht überstimmen ...)

War es hilfreich?

Lösung 2

SOME KEY TIPS TO NOTE WHEN TRYING TO ACHIEVE USER INSTANCE BACKUP

a.) Connecting

Your connection string should look like this:

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MyDatabase.mdf;Integrated Security=True;User Instance=True;Database=MyDatabaseAlias

It is essential that your connection string gives the connection an alias Database=MyDatabaseAlias - this alias cannot be duplicated concurrently on the same machine or your connection may fail.

b.) Backing Up

As pointed out above, the Transact SQL to backup a database is the same on SQL MSDE/2000/2005/2008/R2 - once you have your database attached and aliased!

BACKUP DATABASE MyDatabaseAlias TO DISK = 'c:\backups\mydatabase_20101117.backup'

Whats truly amazing is the bull$h!t errors you can get because your connection string doesnt have the alias Database=MyDatabaseAlias part.

e.g. Unable to open the physical file 'c:\Code\MyProject\App_Data\MyDatabase.mdf' Operating system error 32: "32(The process cannot access the file because it is being used by another process.)".BACKUP DATABASE is terminating abnormally.

c.) Restoring

USE [master]; RESTORE DATABASE MyDatabaseAlias FROM DISK = 'c:\backups\mydatabase_20101117.backup'  WITH REPLACE

Do not forget the all essential USE [master]; at the beginning of this statement (and note that its all on one line for those executing the command from a DataContext or similar) If you do, it wont be able to overwrite the existing database because you'll still be connected to it.

Once again, the assortment of totally misleading errors you might receive here, due to an invalid connection string, is endless.

Andere Tipps

Um, if it's a user instance, then the simplest backup strategy is to copy the file. (whilst it's not connected to SQL Server).

If you need a more comprehensive backup strategy (e.g. transactional backups), then you really should be looking at a more comprehensive database (e.g. a "normal" one attached to a full SQL Server instance)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top