Does anyone have example for setting up a job to reduce SQL Server max memory and recycle SQL server service? I have both SQL Server 2008 and SSAS running on the same machine (Don't ask me why, I have to live with it for now!). Since we run ETL and Cube generation in sequence, I wanted to allocate large portion of memory to SQL server right before ETL jobs start, and do the same for SSAS right before Cube generation starts. 

Is there a way to automate this dynamic memory increase/decrease operations via a job? 

Could someone with experience in this please share your thoughts/scripts?
Max/Min Server Memory setting in SQL 2008 is the buffer pool.  They do not include the memory that is allocated for worker threads, multipage allocator, DLLs and components that SQL loads in its address space, backup and restore operations, SSIS, SSAS, SSRS, and so on.  Set Max Server Memory low enough to leave sufficient memory available for those things not included in the buffer pool.  Windows will allocate the memory for you.  

If it is your desire to have the Max Server Memory setting to be higher during the day, and adjust it lower for the ETL/SSAS jobs, then raise it back up again once they are completed, then you can script that with the following (#### is the MB being set, i.e. 1024):

sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'max server memory', ####;
GO
RECONFIGURE;
GO

Be warned that setting it to a lower number does not always result in the immediate return of memory to Windows.  If the memory is in use, SQL will release when it is no longer in use.