In a previous post, I mentioned that I had to use dynamic SQL to handle the switching of the context of the query in order to accomplish what I wanted. I had also mentioned that I would be putting out another blog post regarding that dynamic SQL and here we are!
As a recap, in that post I was attempting to dynamically calculate the server memory requirements based on the physical memory installed on the machine. I’ll also mention again that Microsoft changed the structure of the DMV that was used between SQL Server 2012 and SQL Server 2008 R2 and lower. In order to run the query on all servers, I had to determine a way to dynamically handle the appropriate structure for the various versions of SQL Server we have.