Gathering physical memory for SQL 2005..SQL 2014

Hi All,
I'm trying to write a query to gather physical memory across my SQL servers (from SQL 2005 to SQL 2012).
However, the sys.dm_os_sys_info DMV (the column for physical memory) is not the same after the switch to SQL 2012+.
Here is the original query:
SELECT
@@SERVERNAME AS ServerName,
CASE WHEN LEFT(CAST(serverproperty('productversion') as char), 1) = 9 THEN '2005'
WHEN LEFT(CAST(serverproperty('productversion') as char), 4) = 10.0 THEN '2008'
WHEN LEFT(CAST(serverproperty('productversion') as char), 4) = 10.5 THEN '2008R2'
WHEN LEFT(CAST(serverproperty('productversion') as char), 2) = 11 THEN '2012'
END AS MajorVersion,
SERVERPROPERTY ('productlevel') AS MinorVersion,
SERVERPROPERTY('productversion') AS FullVersion,
SERVERPROPERTY ('edition') AS Edition,
SERVERPROPERTY('collation') as Collation,
cpu_count as CpuCount,
physical_memory_in_bytes/1024/1024 as PhysMemMB
FROM [sys].[dm_os_sys_info]
If I run that on SQL 2014, it fails because 'physical_memory_in_bytes' is now called 'physical_memory_kb'
I tried to do an IF..THEN..ELSE:
IF (cast(serverproperty('productversion') as char) like '11.%')
Then change the query accordingly but it would fail because i guess when it tried to parse the whole code, one of the T-SQL variations would have a column that did not exist in that particular version of SQL Server.
Is there a way I can get physical memory across SQL 2005..SQL 2012 or rewrite the T-SQL above to be able to run on both?
Thanks in advance

Oh it seemed like you are asking SQL Server memory. the name for physical memory column ha changed only in SQL Server 2012. I wrote below script  just first run select SERVERPROPERTY('ResourceVersion')  to get exact resource database version of
SQL Server 2012 and then replace it in below script
IF cast ( SERVERPROPERTY('ResourceVersion') as char (10) )= '11.00.2000'--2012 resource database version
select (physical_memory_kb/1024)as Physical_mem_MB from sys.dm_os_sys_info
else
select (physical_memory_in_bytes/1024/1024) as physical_mem_MB from sys.dm_os_sys_info
Edit: A more optimized query
If cast (LEFT( CAST(SERVERPROPERTY('ResourceVersion') AS VARCHAR(20)),2) as INT) in ('11','12')
select (physical_memory_KB/1024) as Physical_Mem_MB from sys.dm_os_sys_info
--else it uses for 2005-08R2
else select (physical_memory_in_bytes/1024/1024) as Physical_Mem_MB from sys.dm_os_sys_info
Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
My Technet Articles
Hi Shanky,
Doesn't work and that's what I meant in my initial post..when I run that code against a SQL 2012 instance, it parses fine but when I execute it I get:
Msg 207, Level 16, State 1, Line 6
Invalid column name 'physical_memory_in_bytes'.

Similar Messages

  • Restore Log with Standby Mode on VHDX disk problem - hotfix for SQL 2014 needed

    Restore Log with Standby Mode on Virtual VHDX disk cause a 9004 error in SQL Server 2014 ( test performed on Web edition and Standard version )
    Similar Bug for SQL 2008R2 is already registered with number hotfix
    KB2987585
    Restore operations always fail in Hyper-V R2 Server in situations ( text copied from
    KB2987585 page )
    The primary database has its transaction log file (.ldf) stored on a disk that has "Bytes per Physical Sector" set as 512 bytes.
    You take the transaction log backups of this database, and then you try to restore it by using the standby option on the secondary database.
    The secondary database transaction log file (.ldf) is located on a VHDX disk that has "Bytes per Physical Sector" set as 4,096 bytes.
    In this scenario, the restore operation fails and returns the following error message:
    Error: 9004, Severity: 16, State: 6.
    An error occurred while processing the log for database '<databasename>'. If possible, restore from backup. If a backup is not available, it might be necessary to rebuild the log.
    After this error occurs, the secondary database goes into a suspect state.
    So restore from Generation1 to Generation2 machine ( where only VHDX disk is possible ) always fails and database is not accessible.
    Please create hotfix for SQL 2014 version

    Please create hotfix for SQL 2014 version
    This is a community forum, no one of use can create a hotfix for SQL Server.
    Raise a case at Microsoft Support or create an entry at MS Connect:
    http://connect.microsoft.com/SQLServer
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Finally! T-SQL Reference for SQL 2014 available for download!

    With a mere delay of four month since the release, it is now possible to download the T-SQL Reference for SQL 2014 for your local copy of Books Online. Due to some reorganisations of the reference material on MSDN, the language reference was misisng from
    the initial download.
    To get the reference, you need to use Manage Help Settings, which you find the SQL 2014 program group. Select the option "Install content from online". Once all information has been loaded, scroll down to the SQL Server 2014 group and you will
    SQL Server Language Reference with an Add option, which you should select.
    Now, SQL 2014 uses Help Viewer 1.0, which is very poor, and versions 2.0 and 2.1 which ships with VS 2012/2013 is much more pleasant to use. Thanks to SQL Server MVP Simon Sabin, you can get the SQL 2014 into Help Viewer 2.x in this way. Go to
    https://helpviewerredirector.codeplex.com/
    save the file to a directory. Open a command prompt in that directory and run "HelpViewerRedirector download". Then in Help View, go to manage settings, and select install content from disk. Browse to the folder and select the files you want to see
    in Help Viewer 2.1.
    Erland Sommarskog, SQL Server MVP, [email protected]

    To get the reference, you need to use Manage Help Settings, which you find the SQL 2014 program group. Select the option "Install content from online". Once all information has been loaded, scroll down to the SQL Server 2014 group and you will
    SQL Server Language Reference with an Add option, which you should select.
    If you need more detailed instructions on this part, see the comment from Microsoft added today (2014-08-01) to
    http://connect.microsoft.com/SQLServer/feedback/details/859047/t-sql-reference-and-xquery-reference-missing-from-downloadable-version-of-bol-2014
    Erland Sommarskog, SQL Server MVP, [email protected]

  • SQLEXPRWT_x64_ENU.exe for SQL 2014 express seems to be incomplete?

    Hi,
    I have downloaded the executable SQLEXPRWT_x64_ENU.exe for SQL 2014 express several times, but every time I run the executable, when it is almost done extracting I get the error: Extraction failed.
    When I run the setup.exe in the directory where the extracted files reside, the installation will eventually fail with the error it is missing files (which sounds logical seen the previous error).
    So it occurs to me that the "SQL 2014 Express With Tools" executable (SQLEXPRWT_x64_ENU.exe) found at http://www.microsoft.com/en-us/download/details.aspx?id=42299 is broken.
    Anyone with the same issues or have any idea where I can download the correct executable?
    By the way the total size of the separate downloads of the management tools and the sql express version is larger than the download with the tools included:
    SQLEXPRWT_x64_ENU.exe = 833.2 MB
    SQLEXPR_x64_ENU.exe + SQLManagementStudio_x64_ENU.exe = 880.6 MB
    For me this confirms my suspicion 
    Regards,
    Erik

    Hi,
    Based on your description there IS something wrong with the download. Have you actually downloaded it and tried what I am describing, so you can rather base it on experience than just a description?
    1. If I need a third party application to successfully extract a self-extracting executable, than to me there is something wrong with the download.
    2. the /X makes no sense because I get the same specify location dialogue box if I just run the executable.
    Taken all the above into account including the size differences mentioned in my starting post, to me the self extracting executable is still broken/faulty/incomplete.
    Hi Erik,
    Actually, I have done a test, firstly downloaded the SQLEXPRWT_x64_ENU.exe file from the same website:http://www.microsoft.com/en-us/download/details.aspx?id=42299, and extracted it from the command prompt, and then I installed the SQL 2014 Express on my computer
    successfully.
    Since your self-extracting executable is still incomplete.I recommend you to check if there is an anti-virus software or other third-party software on your computer blocking the process of downloading, also you can try to download the SQLEXPRWT_x64_ENU.exe
    file from a different browser, and check if you can implement the extraction successfully.
    In addition,this issue might also be caused by your Internet Service Providers (ISP). In order to enhance the network performance, some ISPs may deploy cache servers, when you download the SQLEXPRWT_x64_ENU.exe file from Microsoft official website, it
    will redirect your installation media file to the local cache server, and it might cause the download file to be broken, then you encounter the error when extracting file. I recommend you to contact to your ISP to solve the problem, then download again
    and check if it can extract successfully .
    Thanks
    Lydia Zhang

  • ": Not enough physical memory for SHM_SHARE_MMU "

    Dear ALL,
    ": Not enough physical memory for SHM_SHARE_MMU "
    This is an error message which occurs while trying to mount the database on startup. I've two database running of solaris. DB1 is running with 700M shared pool size. I want to run the DB2 database with 400M. But if i specify 400M shared_pool size on DB2 it is not mounting. It is only mounting when I specify 200M size of shared_pool. Machine has 4cpu and 4gb of RAM.
    I've configured the kernel and shemaphore parameter according to the oracle process.
    Any thoughts or suggestions appreciated.

    The whole SGA must fit into physical memory (SGA=shared_pool_size + (db_block_buffer*db_block_size) + log_buffer + java_pool_size).

  • Best practice configuration for SQL 2014 to achieve HA when hosted on Hyper-V 2012R2 cluster

    Hi,
    I've had a hunt around but so far I've not found a conclusive answer to my question.  I am currently moving from a SQL 2008R2 (physical tin) failover cluster to a virtual environment build on Hyper-V 2012R2.  I am building everything with SQL 2014
    SP1.
    I want to achieve the same level of high availability that I currently have and at the same time make sure that I can replicate (DR) data offsite (Azure) in the future.  I have two options with SQL which are clustered instance (basically the same as
    I have now) or AlwaysOn Availability Groups for database level HA. 
    I am unsure which is the best method to use when the SQL nodes are highly available guests on Hyper-V, trying to imagine how the guests will all move around in the case of a host server failure is a bit mind boggling to say the least.
    I am leaning towards a instance failover but I would appreciate any input/advice etc.
    Thanks
    Rob

    Hi Rob, 
    To start with I will not be installing SQL Server 2014 with SP1, as SP1 has bugs and Microsoft has disabled its download. See reference: http://www.eweek.com/database/microsoft-halts-sql-server-2014-sp1-downloads.html
    With regards, I would go for AlwaysOn Availability Groups configuration, because it has several benefits:
    You will get same amount of high availability you normally get with native cluster configuration, if you use AlwaysOn configuration. However, AlwaysOn configuration provides more granular high availability, and fail-over are invisible to the application,
    if you using Availability Group listener to connect to server. 
    You can offload read-only workloads to secondary replica.
    You can perform transaction log backups on secondary replica.
    Reduce production downtime during patching or other planned work on the server.
    So in short, you should use AlwaysOn configuration. 
    Regards,
    Basit A. Farooq (MSC Computing, MCITP SQL Server 2005 & 2008, MCDBA SQL Server 2000)
    http://basitaalishan.com
    Please remember to click "Mark as Answer" on the post that helps you, and to click
    "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • (BUG??) Team Foundation Server 2013 Update 4 Support for SQL 2014

    Scenario: On Windows 2012 R2 x64 I have installed SQL, Reporting Services & AS 2014 (applied all updates through Windows Update), SharePoint 2013 Foundation, and installed Team Foundation Server 2013 RTM (did not configure).
    Before configuring TFS, I applied Update 4 to the server (not update 1,2 or 3 directly). When trying to configure I get the following error:
    ==========================
    TF255146: Team Foundation Server requires SQL Server 2012 SP1 (11.00.3000) or greater. The SQL Server instance you supplied is version 12.0.2254.0.
    TF400403: The Report Server instance specified is version 12.0.2254.0, the minimum supported version is 11.0.3000.
    TF400070: A required version of a component is not installed on the application tier. You must exit the Team Foundation Administration Console and install a supported version of either SQL Server Analysis Services of the SQL Server Client Tools on the application
    tier to ensure that the Analysis Services object model is present for warehouse processing.
    ====================================
    My understanding is that as of Update 2 (or was it 3) that SQL 2014 was supported. However it appears if that particular update is not installed directly it bypasses the check. Can someone verify I am seeing the intended result or is this a bug?

    Hi Jazzy,  
    Thanks for your post.
    And thank you for sharing your experience here. It will be very beneficial for other community members having the similar questions.
    All your participation and support are very important to build such harmonious/ pleasant / learning environment for MSDN community.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • SQL Server Data Tools for SQL 2014 setup

    Hello,
    I have been using SQL server 2008 with Visual Studio 2008 to perform the ETL processes.
    I have recently got SQL 2014 and realized that Business Intelligence Development Studio does not come with it so I have to download SQL Server Data Tools for Visual Basics 2012 or 2013 from:
    https://msdn.microsoft.com/en-us/data/hh297027
    Can someone advise what exactly I have to do if I want to start using SQL  2014 with SSDT? I still have VB 2008 installed and all my packages were created with that version.
    Do I need to download VB 2012 or 2013 plus SSDT and then SSDT? Do I also uninstall VB2008?
    Thanks in advnce

    Hello,
    If you want to keep developing packages for SQL Server 2008 then you need to use BIDS 2008, you cannot use SSDT.
    If you want to upgrade BIDS projects to SSDT, then you can use Integration Services Project Conversion Wizard from Visual
    Studio or SSIS Package Upgrade Wizard from SQL Server Management Studio (SSMS).
    Hope this helps.
    Regards,
    Alberto Morillo
    SQLCoffee.com

  • Where are SQLDOM.msi and SqlSysClrTypes.msi for SQL 2014?

    On the SQL Server 2014 Feature Pack page (http://www.microsoft.com/en-us/download/details.aspx?id=42295), under Data-Tier Application Framework, it says:
    Note: Microsoft SQL Server 2014 Data-tier Application Framework requires Microsoft SQL Server System CLR Types, and Microsoft SQL Server Transact-SQL ScriptDom both of which are available on this page.
    Those things are on that page but, the files are not links so they cannot be downloaded.
    Where can I find SQLDOM.msi and SqlSysClrTypes.msi for SQL Server 2014?

    Where can I find SQLDOM.msi and SqlSysClrTypes.msi for SQL Server 2014?
    Click on the "Download" button, then you can select the packages you want to get:
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • How to create backup maintenance plan for SQL 2014

    Depending on your backup product, it may include a hot backup for SQL - check that too

    I need to create a basic maintenance plan that backs up our DB nightly and also need some pointers on any other maintenance that should be done would be great. Obviously I'm very new to using SQL, trying to get my feet wet.
    This topic first appeared in the Spiceworks Community

  • How to install sql server 2012 using the license of sql 2014

    Hello,
    We want to install sql server 2012 on a server because of an application that can not work with sql server 2014.
    We have a license for sql server 2014. The license is not visible for sql 2014 in our licenses because it is now included in the installation package. We also can not get a license key for SQL 2012 server now.
    How can we get a valid sql server 2012 license key?
    Thanks,
    Gr. Peter.

    Hello Peter, 
    This is a community forum for technical questions & issues.
    For question regarding pricing / licensing please contact a Microsoft sales partner or licensing expert.
    Call (1-800-426-9400), Monday through Friday, 6:00 AM to 6:00 PM PST to speak directly to Microsoft licensing specialist.
    Regards.
    T-SQL Articles
    T-SQL e-book by TechNet Wiki Community
    T-SQL blog

  • Arc is not implemented for SQL Server 2005 physical model

    I added the Arc in my relational model, which is supposed to provide that references are mutually exclusive (so only one refering column can be not null). However there is not any implementation for this in the SQL Server 2005 physical model. The SQL code generated simply ignores the Arc and allows any values for the columns covered by Arc. If we check Oracle physical model. then it generates some trigger, which controls how many columns have values assigned - this is actually an implementation of Arc. But there is nothing of this kind for SQL Server model...
    By the way, implementing this Arc by trigger looks like to heavy approach. The very simple table level check constraint will do the same job. But this is a different subject though.
    Edited by: Otbl on Nov 3, 2011 7:34 PM

    Hi Dmitry,
    it's fixed in Data Modeler 3.1 EA2.
    Philip

  • Does it need effort to upgrade SSRS from SQL Server 2005 to 2014?

    Hi,
    i have a customer who wants to upgrade the their system. for SQL Server part, the current version is 2005, they want to upgrade to 2014. is it possible that don't change any code for SSRS? if have to change, what's the estimated effort? the total RDL files
    are more than 200. 

    Hi dingsheng,
    In this scenario, you don't need to change code for Reporting Services. Those reports can be still available. Please run SQL Server Upgrade Advisor on the report server computer to determine any issues that might prevent you from successfully upgrading.
    For more information, please see:
    Upgrade and Migrate Reporting Services
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • SQL Server Express 2005 to 2014 upgrade and Uninstallation issues

    We have client application running SQL Server Express that connects to a SQL Server 2012 server.  We are attempting to upgrade from Microsoft SQL 2005 express to Microsoft SQL Server 2014
    express – but are having difficulties – especially with uninstall.
    Our understanding is that we needed to follow the following steps:
        First we install Microsoft SQL 2005 express SP4 as required silently
    Start /wait SQLEXPR.exe /qn ACTION=UPGRADE INSTANCENAME="SQLEXPRESS" UPGRADE=SQL_Engine SAPWD=<password>
    SQLACCOUNT="NT AUTHORITY\SYSTEM" SQLPASSWORD= SECURITYMODE="SQL"
        Then try upgrading with Microsoft SQL Server 2014 express, we use following command to do it silently
    SQLEXPR.exe /q /ACTION=upgrade /INSTANCENAME=SQLEXPRESS /ISSVCAccount="NT AUTHORITY\SYSTEM" /IACCEPTSQLSERVERLICENSETERMS
    We see following
        In Control Panel -> Uninstall or change program, we have all the instances listed 2005, 2008, 2012 and 2014.
        How do we uninstall the instance?  , We try uninstalling 2014
    But it is not cleanly uninstalled.
    Questions:
        Is there any way for clean upgrade from Microsoft SQL 2005 express SP3 to Microsoft SQL 2014 express?
        Is there any specific steps suggested to uninstall upgraded SQL 2014 express from system?
        Are we doing anything wrong in commands for silent upgrade?
    Thanks in advance.

    Hello,
    After you perform an in-place upgrade it’s normal to find the binaries and references of the old version of SQL Server on the Start Menu and Control Panel -> Programs and Features. That’s by design. After you have successfully upgraded an instance, you can
    remove the old binaries.
    IfIf you find some remnants after uninstalling SQL Server 2014, please perform the following steps to manually uninstall it:
    1. Uninstall all SQL Server 2014 components you can using Control Panel -> Programs and
    Features
    2. Backup the registry.
    3. Delete the following keys in regedit:
        --HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server
        --HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer
    4. Go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall and delete
    all the sub-keys referencing SQL Server.
    5. Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services and delete all the keys referencing
    SQL Server.
    6. Rename all the SQL Server folders in the computer like
    C:\Program Files\Microsoft SQL Server and subfolders.
    Hope this helps.
    Regards,
    Alberto Morillo
    SQLCoffee.com

  • SQL SERVER PHYSICAL MEMORY USAGE HIGH

    HI Teams,
    i am  going threw one of my production high physical memory usage in SQL Server. It always
    around 90%.When i reboot the server, it will initially good but end of the day it will around 95 to 98% physical memory usage.
    please give the valid solutions..,
    Regards,
    DBA 

    This is an expected/normal behaviour in SQL Server box. Memory management is highly dynamic in SQL Server and will use the complete memory allocated to SQL Server. It is also important to set the MAX SERVER MEMORY for the SQL Server instance. You may not
    need to worry about this unless you find any performance issues.
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped.
     [Blog]

Maybe you are looking for