Hier ein Script wie man einen Script erzeugt der alle Datenbanken eines SQL Servers sichert:
SET NOCOUNT ON;
DECLARE @DatabaseName NVARCHAR(128)
DECLARE DB_Cursor CURSOR FOR
Select Name as DatabaseName from sys.databases
order by DatabaseName
OPEN DB_Cursor;
FETCH NEXT FROM DB_Cursor INTO @DatabaseName;
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT '--============================================='
PRINT '--BACKUP QUELLSERVER ' + @DatabaseName
PRINT '--============================================='
PRINT 'BACKUP DATABASE [' + @DatabaseName + ']'
PRINT 'TO DISK = N''E:\' + @DatabaseName + '.bak'''
PRINT 'WITH COPY_ONLY, '
PRINT 'NOFORMAT, '
PRINT 'NOINIT, '
PRINT 'NAME = N''' + @DatabaseName + '-Full Database Backup'', '
PRINT 'SKIP, '
PRINT 'NOREWIND, '
PRINT 'NOUNLOAD, '
PRINT 'STATS = 10;'
PRINT 'GO'
PRINT ''
FETCH NEXT FROM DB_Cursor INTO @DatabaseName;
END;
CLOSE DB_CURSOR;
DEALLOCATE DB_CURSOR;
GO
|