I am new to t-sql programming. I have a background in Java, Javascript and numerous other programming languages. I'm trying to set the value of the @notes variable. My code is below.
Basically, what I want to do is set the @notes variable if the @minBatch and @maxBatch are not null. I added a print statement to ensure that @minBatch and @maxBatch are the values I'm passing in.
In short, what's wrong with the following code?
set @notes =
case
when @minBatch != null and @maxBatch != null then
case
when @minBatch != @maxBatch then
'Start batch: ' + cast(@minBatch as varchar(8)) + ' End batch: ' + cast(@maxBatch as varchar(8))
else
'Batch ' + cast(@minBatch as varchar(8))
end
else
null
end