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
Post a Comment