The following code works fine as far as the logic goes but can someone tell me why the salesrep variable always displays the max length even though I am telling it to display only 22 characters?
case when substring(b.jobnumber,1,1) ='N' then (select left(salesrep,22) from db1..import_order_table where b.jobnumber=import_order_table.orderid) else (select left(description,22) from db2..salesrep where o.salesrepcode=salesrep.code) end as salesrep
case when substring(b.jobnumber,1,1) ='N' then (select left(salesrep,22) from db1..import_order_table where b.jobnumber=import_order_table.orderid) else (select left(description,22) from db2..salesrep where o.salesrepcode=salesrep.code) end as salesrep