I think you're looking at the most common cause of failure on a
restore: the database is not in DBO or single-user mode. I don't know
off-hand how you would force the DB into DBO mode in a job, but I'm
certain there is a way. The more I look at the error message the more
certain I am as to this is what is happening.
And you should be able to look up the error message numbers on TechNet
to get the English version.
claus.rauchschindel@dds.de (FoxRunner) wrote in message news:<b7c717fb.0312090728.1b374ba1@posting.google. com>...
> Hi folks,
>
> I got a script which restores a database. It works fine
> if it is running in my Query Analyzer.
>
> It fails when I put this script in an automated schedule using the
> SQL agent.
>
> This is my script
>
> RESTORE DATABASE [RestoreTest]
> FROM DISK = N'E:\sqlbak\RestoreTest.BAK'
> WITH FILE = 1, NOUNLOAD , STATS = 10, RECOVERY
>
> and this is the error message from the scheduler (Sorry its in German)
>
> Executing as User dbo. Exclusiv access to database not possible
> because
> it is in use (which is not).. Rest may be clear ;-))
>
> Ausführt als Benutzer: dbo. Exklusiver Zugriff auf die Datenbank ist
> nicht möglich, da die Datenbank gerade verwendet wird. [SQLSTATE
> 42000] (Fehler 3101) RESTORE DATABASE wird fehlerbedingt beendet.
> [SQLSTATE 42000] (Fehler 3013). Fehler bei Schritt