Execute the generated SQL Goto the next database SET = 'BACKUP LOG ' ' TO DISK = ''' WITH INIT, NAME= ''' NOSKIP, NOFORMAT' SET = 'BACKUP DATABASE ' ' TO DISK = ''' WITH DIFFERENTIAL, INIT, NAME= ''' NOSKIP, NOFORMAT' SET = 'BACKUP DATABASE ' ' TO DISK = ''' WITH INIT, NAME= ''' NOSKIP, NOFORMAT' SET = ' log backup for ' Generate the dynamic SQL command to be executed SET = ' differential backup for ' = 'L' Provide the backup a name for storing in the media Create backup filename in path\filename.extension format for full,diff and log backups SET = '[' (SELECT DBNAME FROM WHERE ID = Set the current date and time n yyyyhhmmss format Database Names have to be in format since some have - or _ in their name IF where DBNAME IN ('tempdb','Northwind','pubs','AdventureWorks')ĮLSE IF where DBNAME IN ('tempdb','Northwind','pubs','master','AdventureWorks') Filter out databases which do not need to backed up If specific database is chosen to be backed up only pick that out from INTO (DBNAME) Pick out only databases which are online in case ALL databases are chosen to be backed up Parameter2: backupType F=full, D=differential, L=logĬREATE PROCEDURE sysname = nvarchar(200) Description: Backup Databases for SQLExpress This code released under the terms of the Then Create two tasks in Task Scheduler, one for full and one for diff. It is usefull to create two batch files, one for full backup a and one for diff backup. Then create batch file according to the article. Just use this script to dynamically backup all databases on the server.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |