customizing Ola Hallengren script

  • Hi experts,

    I am trying to:

    -take only 2 user databases full backup (Database1 and Database2) with checksum and verify backup

    - Integrity check (Database1 and Database2)

    -Index Optimize (Database1 and Database2)

    where and what should I change on the script or even just change on the sql job which are created when I ran the script.

    I tried putting (comma) but didn't work.

  • Tac11 (12/8/2015)


    I tried putting (comma) but didn't work.

    Put comma where? Didn't work how? Could you please provide the scripts of what you are trying to do?


    Alex Suprun

  • To do what you want, change the Database Backup job step's parameters, not Ola's script. See Ola's web site for examples.

    If you want different databases to be treated differently (when backed up), add another step or script out Ola's existing job. If scripted, change the job name and remove the existing job schedule. Edit the new step's parameters. If scripted, run the edited script and use the GUI to create a new schedule.

  • Thanks Alexander and SoHelpmeCodd for taking time to reply. My question was if I have 7 databases on my instance but i just want to setup job for 'Database1' and 'Database2' (excluding rest of 5 databases), how do I do that? I made changes on the script (below) and also changed on sql job (which it creates on sql agent, below below CMD script) but didn't work.

    -------------DatabaseBackup----------

    EXECUTE dbo.DatabaseBackup

    @databases = 'database1', 'database2',

    @Directory = 'C:\Backup',

    @BackupType = 'FULL',

    @verify = 'Y',

    @Compress = 'Y',

    @checksum = 'Y',

    @CleanupTime = 24

    sqlcmd -E -S $(ESCAPE_SQUOTE(SRVR)) -d master -Q "EXECUTE dbo.DatabaseBackup @databases = 'database1', 'database2' @Directory = 'C:\Backup', @BackupType = 'FULL'" -b

    -----------DatabaseIntegrityCheck-----------

    EXECUTE dbo.DatabaseIntegrityCheck

    @databases = 'database1', 'database2',

    @CheckCommands = 'CHECKDB'

    sqlcmd -E -S $(ESCAPE_SQUOTE(SRVR)) -d master -Q "EXECUTE dbo.DatabaseIntegrityCheck @databases = 'database1', 'database2'" -b

    ------------------IndexOptimize-----------------------

    EXECUTE dbo.IndexOptimize

    @databases = 'database1', 'database2',

    @FragmentationLow = NULL,

    @FragmentationMedium = 'INDEX_REORGANIZE,INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE',

    @FragmentationHigh = 'INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE',

    @FragmentationLevel1 = 5,

    @FragmentationLevel2 = 30

    sqlcmd -E -S $(ESCAPE_SQUOTE(SRVR)) -d master -Q "EXECUTE dbo.IndexOptimize @databases = 'database1', 'database2'" -b

  • @Databases = 'database1, database2',

  • Cool. Thanks SoHelpMeCodd!!!!

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply