I need help with the following query. I want to put a condition on the returned value of select command which is an integer between 0 and any number.
DECLARE @month varchar(50);
set @month ='01-03-05-07-09-11'; <--- clarification: these are all months
Declare @cur_month int;
set @cur_month = Month(GetDate());
select charindex(str(@cur_month), @month);
I essentially want
If ( select charindex(str(@cur_month), @month))
// successful
I get error
An expression of non-boolean type specified in a context where a
condition is expected, near ‘print’.
I tried CAST and CONVERT but to no Avail. As you can see, I am trying to see if the current month is in my @month field, I want to execute certain actions if it is.
Taking the answer from @PaulStock with a couple tweaks will work better.
Changes from PaulStock’s answer
Actual code