insert into tblmail(sendTo, sendBcc, [subject], Note)
select '
[email protected]', 'sd@sdf','Account Canceled',
case WHEN EXISTS (select 1 from #temp where refund > 0 )
then cast(@custID as varchar) + ' has been cancelled, refund amount $' + refund + ' by ' + (select displayName from tblAd where id = @adID) + '.'
else cast(@custid as varchar) + ' has been cancelled with no refund ' + ' by ' + (select displayName from tblAd where id = @adID) + '.'
end