Memory cap for SQL

This is the simple script to set the memory cap for SQL:
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'max server memory', 4096; //Set here
GO
RECONFIGURE;
GO