Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

SQL - TSQL - Backup Job bricht hin und wieder ab

Empfohlene Antworten

Veröffentlicht

Hi,

ich hab da ein Problem mit einem Backup, das läuft mal, dann mal wieder nicht. Es ist gescheduled und wird täglich um 20 Uhr ausgeführt. Das geschieht über die Aufträge des SQL Server-Agents. Wenn man nun einen neuen Zeitplan hinzufügt, der nur einmalig läuft, wird das Backup IMMER erfolgreich beendet. Nur wenn es täglich laufen soll, klappt es in zwei von fünf Fällen. UNd dann auch immer unteschiedlich, mal Montag und Freitag, dann mal nur Dienstags usw...

Es gibt keine anderen Job, der in der Zeit auf dem SQL-Server läuft.

Es ist ein MSSQL 2008 R2 x64 auf einem Windows 2008 R2 Server.

Hier der Code:

use master;

go


DECLARE UserDatabases_CTE_Cursor Cursor

FOR


-- Selecting user database names.

select name as DatabaseName

from sys.sysdatabases

where ([dbid] > 4) and ([name] not like '$')


OPEN UserDatabases_CTE_Cursor

DECLARE @dbName varchar(100);

DECLARE @backupPath varchar(100);

DECLARE @backupQuery varchar(500);


-- make sure that the below path exists

set @backupPath = 'D:\Backup\USRDB\'


Fetch NEXT FROM UserDatabases_CTE_Cursor INTO @dbName

While (@@FETCH_STATUS <> -1)


BEGIN

-- Backup SQL statement

set @backupQuery =  'backup database ' + @dbName + ' to disk = ''' + @backupPath + @dbName + '_[' + REPLACE( convert(varchar, getdate(), 109), ':', '-') + '].bak'''


-- Print SQL statement

print @backupQuery


-- Execute backup script

EXEC (@backupQuery)


-- Get next database

Fetch NEXT FROM UserDatabases_CTE_Cursor INTO @dbName

END


CLOSE UserDatabases_CTE_Cursor

DEALLOCATE UserDatabases_CTE_Cursor

GO

Gibts hier Optimierungsbedarf?

Danke und sonnige Grüße aus Frankfurt

Lloyd

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.