Well, for starters, this modification works:
DECLARE @strNonsense_02 [nvarchar](66)
SET @strNonsense_02 = 'nonesense_02'
DECLARE @searchtype[int]
SET @searchtype = 1
BEGIN
if (@searchtype = 1)
BEGIN
select @strNonsense_01 --cls_code,cls_name from Cls_master where cls_code=@cls_code
END
else
BEGIN
select @strNonsense_02 -- from Cls_master where cls_name=@cls_name
END
END
Returns:
nonesense_01
And:
BEGIN
if (@searchtype = 65)
BEGIN
select @strNonsense_01 --cls_code,cls_name from Cls_master where cls_code=@cls_code
END
else
BEGIN
select @strNonsense_02 -- from Cls_master where cls_name=@cls_name
END
END
Returns:
nonsense_02
Not privy to the data, that's all I can venture from the description of the problem ...