I try to make a stored procedure on SQL Server but when I set the select results into one variable it returns NULL.
example:
set @myvar= select Sum(Values) from myTable
but when I make a select without a function, the variable returns the expected value.
You have a mixture of the two ways to set a variable here.
It should be either.
set @myvar = (select sum(Values) from myTable)
OR my preference would be
select @myvar = sum(Values) from myTable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With