I am trying to run a totally dynamic update statement to get Number of Cpu's, Number of cores, Memory and version of a the server it is ran on. The portion I have for the version number runs a stored procedure in the master DB and I need to pull out just the Character_Value column do I can get version and build number to push into the table.
UPDATE DBA_STATS.dbo.HOSTS
SET CPUNUM = (SELECT (cpu_count / hyperthread_ratio) FROM master.sys.dm_os_sys_info),
CORENUM = (SELECT CASE
WHEN hyperthread_ratio = cpu_count
THEN cpu_count
WHEN (([cpu_count] - [hyperthread_ratio]) / ([cpu_count] / [hyperthread_ratio])*cpu_count) = 0
THEN cpu_count
ELSE (([cpu_count] - [hyperthread_ratio]) / ([cpu_count] / [hyperthread_ratio])*cpu_count)
END FROM sys.dm_os_sys_info),
MEMORY = (SELECT physical_memory_in_bytes/1073741824 FROM sys.dm_os_sys_info),
DOMAIN = (SELECT DEFAULT_DOMAIN()),
VERSION = (exec master.dbo.xp_msver 'WindowsVersion')
WHERE NAME = @@ServerName
I have an error obviously because the stored procedure xp_msver is giving me 4 columns. All I want to pull out is Character_Value column. Does anyone have an idea of how to accomlish this?