![]() set backup string to be executed (this includes the database backup and verification of the file created set variable to required name of backup file (.bak) if, used to set connection string for servers with named instances (for remote execution over ls's) fetch statement for cursor to return the first row declare cursor to loop round temp table and backup each instance row) set variable with current date and time (YYYMMDD_HHMM) populate a temp table with db's to be backed up SET = ' - 'AT ' - to run remotelyįETCH NEXT FROM dbname_cursor INTO dbname_cursor RESTORE VERIFYONLY FROM DISK = N''' ''' WITH FILE = NOUNLOAD, NOREWIND Backup information for database ''''' ''''' not found.'', 16, 1) end If is null begin raiserror(N''Verify failed. Select = position from msdb.backupset where database_name=N''' ''' and backup_set_id=(select max(backup_set_id)įrom msdb.backupset where database_name=N''' ''' ) TO DISK = N''\\' '\' ''' WITH NOFORMAT, NOINIT, NAME = N''' '-Full Database Backup'', SKIP, NOREWIND, NOUNLOAD, STATS = 10 ![]() SELECT server, dbname FROM dbname_cursorįETCH NEXT FROM dbname_cursor INTO = 0 SET = 's$\Microsoft SQL Server\MSSQL.1\MSSQL\DO NOT DELETE\' INSERT INTO VALUES('server2','database_on_server2') INSERT INTO VALUES('server1','database_on_server1') DECLARE TABLE(server VARCHAR(50),dbname VARCHAR(50))
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |