Sql Server 2012 Enterprise [hot] -

-- Log start INSERT INTO dbo.IndexMaintenanceLog (TableName, Action, StartTime, Status) VALUES (@SchemaName + '.' + @TableName, 'Enterprise Optimize', GETDATE(), 'Running');

-- Get max partition number SELECT @MaxPartition = MAX(partition_number) FROM sys.partitions WHERE object_id = @ObjectID; sql server 2012 enterprise

IF @ObjectID IS NULL BEGIN RAISERROR('Table not found', 16, 1); RETURN; END; -- Log start INSERT INTO dbo

SET @ObjectID = OBJECT_ID(@SchemaName + '.' + @TableName); sql server 2012 enterprise