It's nice that SQL2008R2 now has that DVM.
But for other systems, we can use a more... let's call it brute
----------------------
declare
@VirOrPhys[nvarchar](50),@manu-2[nvarchar](50)
create table #OSinfo(OSinfo varchar (255))
insert into #OSinfo
exec master..xp_cmdshell 'systeminfo'
set @manu-2 =(select ltrim(SUBSTRING(OSinfo,CHARINDEX(' ',OSinfo),LEN(OSinfo)))
from #OSinfo
where OSinfo like '%System%' and
OSinfo like '%Manufacture%')
if (@Manu not like '%VMware%')
begin
set @VirOrPhys='Not Virtual'
end
else
begin
set @VirOrPhys='Virtual'
end
select @VirOrPhys, @manu-2
DROP TABLE #OSinfo