Virtual or Physical

  • Hi

    I am looking for a way to determine if the server is Physical or Virtual using SQL Server 2008. Can you please let me know if there any easy way to find out without using xp_readerrorlog? Also this info is available in DMV from SQL 2008 R2. Any help or input will be useful for me.

    Thank you

  • there's a DMV with that info:

    select s.virtual_machine_type,

    s.virtual_machine_type_desc

    FROM sys.dm_os_sys_info s

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • This works from SQL 2008 R2 onwards. But in SQL 2008 it doesnt work.

  • You can try doing something like this:

    CASE

    WHEN RTrim(@@VERSION) LIKE '%(VM)' + CHAR(10) THEN 'Virtual'

    WHEN RTrim(@@VERSION) LIKE '%(Hypervisor)' + CHAR(10) THEN 'Virtual'

    ELSE 'Physical'

    END AS Machine_Type

    ...but I can't vouch for the reliability of this.

  • Thank you. It works for me.

  • usually the error log will identify virtual machines as the instance starts, look for the hardware info

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply