sql server - Parameters are not taken by execute statement -


i trying execute below given code, execute statement not taking parameters.

what other way use parameters execute statements?

declare @ver nvarchar(128)  set @ver = cast(serverproperty('productversion') nvarchar)  set @ver = substring(@ver, 1, charindex('.', @ver) - 1)  select @ver    declare @chvcpucount varchar(256)  declare @bintmemory bigint   if @ver < 11  execute('select @chvcpucount = cpu_count  , @bintmemory = (physical_memory_in_bytes / 1048576)  master.sys.dm_os_sys_info')  else  execute('select @chvcpucount = cpu_count  , @bintmemory = (physical_memory_kb / 1048.576)  master.sys.dm_os_sys_info')  select @chvcpucount, @bintmemory 

thanks !

you don't need use dynamic sql this. do

if @ver < 11     select @chvcpucount = cpu_count, @bintmemory = (physical_memory_in_bytes / 1048576)    master.sys.dm_os_sys_info  else     select @chvcpucount = cpu_count, @bintmemory = (physical_memory_kb / 1048.576)    master.sys.dm_os_sys_info 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -