How to create runbook for Azure Automation RRS feed

  • Question

  • Hope this is the correct forum.  I have a maintenance query that needs to be run each night (posted below my signature). I am currently using ApexSQL Build to run the query against all databases (172 databases on same server).  I have recently learned about the Automation tool in Azure that will allow me to create a Runbook and schedule the Runbook to run each night at a specified time.  The problem is I am confused and don't know where to start.  Any help is appreciated.



    DECLARE @sql nvarchar(MAX);
    SELECT @sql = (SELECT 'UPDATE STATISTICS ' + DB_NAME() + '.' + rtrim( + '.' + rtrim( + ' WITH FULLSCAN, ALL; '
    from sys.sysobjects so
    join sys.schemas sc
    on so.uid = sc.schema_id
    where so.xtype = 'U'
                   FOR XML PATH(''), TYPE).value('.', 'nvarchar(MAX)');
    PRINT @sql
    EXEC (@sql)

    • Edited by vcotton Friday, March 11, 2016 6:22 PM
    Friday, March 11, 2016 6:20 PM


All replies