Could anyone please assist me on the following SQL (MSS) to be converted in to Dynamic TypeList? (don't get scared since its big sql, but its repeating CASE statement though!)
select id_num_vp_holder,
sa_vp_cde,
vp_num,
case when vp_veh_year is not null and length(rtrim(vp_veh_year)) > 0 then
rtrim(ltrim(vp_veh_year))
else
''
end
+
case when vp_veh_make is not null and length(rtrim(vp_veh_make)) > 0 then
case when vp_veh_year is not null and length(rtrim(vp_veh_year)) > 0 then
' ' + rtrim(ltrim(vp_veh_make))
else
rtrim(ltrim(vp_veh_make))
end
else
''
end
+
case when vp_veh_modle is not null and length(rtrim(vp_veh_modle)) > 0 then
case when (vp_veh_year is not null and length(rtrim(vp_veh_year)) > 0)
or (vp_veh_make is not null and length(rtrim(vp_veh_make)) > 0) then
' ' + rtrim(ltrim(vp_veh_modle))
else
rtrim(ltrim(vp_veh_modle))
end
else
''
end as VehicleDescription,
case when cm_sa_vehcl_reg.loc_cde is not null then
rtrim(ltrim(loc_desc))
else
''
end
+
case when cm_sa_vehcl_reg.bldg_cde is not null then
case when cm_sa_vehcl_reg.loc_cde is not null then
' - ' + rtrim(ltrim(building_desc))
else
rtrim(ltrim(building_desc))
end
else
''
end as ParkingLocation,
rtrim(ltrim(td_sa_vp_type_view.description)) as TypeOfPermit,
rtrim(ltrim(cm_sa_vehcl_reg.sa_vp_cde)) + '-' +
rtrim(ltrim(cm_sa_vehcl_reg.vp_num)) as PermitNumber,
case when vp_end_dte is null then
'No expiration date'
when vp_end_dte < getdate() then
'Permit has expired'
else
convert(varchar(15), vp_end_dte, 101)
end as PermitExpirationDate,
rtrim(ltrim(vp_veh_licns_num)) as LicensePlateNumber
from cm_sa_vehcl_reg left outer join location_master
on cm_sa_vehcl_reg.loc_cde = location_master.loc_cde
left outer join building_master
on cm_sa_vehcl_reg.bldg_cde = building_master.bldg_cde
join cm_sa_v_prmt_mstr
on cm_sa_vehcl_reg.sa_vp_cde = cm_sa_v_prmt_mstr.sa_vp_cde
left outer join td_sa_vp_type_view
on cm_sa_v_prmt_mstr.sa_vp_type = td_sa_vp_type_view.value
where id_num_vp_holder = strhostid
Just give me a code sample for the following...
case when vp_veh_year is not null and length(rtrim(vp_veh_year)) > 0 then
rtrim(ltrim(vp_veh_year))
else
''
end
+
case when vp_veh_make is not null and length(rtrim(vp_veh_make)) > 0 then
case when vp_veh_year is not null and length(rtrim(vp_veh_year)) > 0 then
' ' + rtrim(ltrim(vp_veh_make))
else
rtrim(ltrim(vp_veh_make))
end
else
''
end
+
case when vp_veh_modle is not null and length(rtrim(vp_veh_modle)) > 0 then
case when (vp_veh_year is not null and length(rtrim(vp_veh_year)) > 0)
or (vp_veh_make is not null and length(rtrim(vp_veh_make)) > 0) then
' ' + rtrim(ltrim(vp_veh_modle))
else
rtrim(ltrim(vp_veh_modle))
end
else
''
end as VehicleDescription,
Appreciate your help on this. Thanks.