Click here to Skip to main content
15,905,875 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In this following select query MachinaryName and Model are concatanated. If any of the field is empty then what should be done.
Please explain. Thank you for your valuable time

SQL
Select mp.MPCode, convert(varchar(102), mp.MaintenceStartDate, 106) as MaintenceStartDate,
mp.Description, mp.MaintencePlanType, mp.MDCode, md.MachinaryName+ '-' +md.Model as [Machine Name and Model]
from tblMaintencePlanEntry mp inner join tblMachinaryDetails md on mp.MDCode=md.MDCode  order by mp.MPCode desc
Posted
Updated 6-Jul-13 21:29pm
v2

1 solution

Use the ISNULL function:
SQL
Select mp.MPCode, convert(varchar(102), mp.MaintenceStartDate, 106) as MaintenceStartDate,
mp.Description, mp.MaintencePlanType, mp.MDCode, ISNULL(md.MachinaryName, '???') + '-' + ISNULL(md.Model, '???') as [Machine Name and Model]
from tblMaintencePlanEntry mp inner join tblMachinaryDetails md on mp.MDCode=md.MDCode  order by mp.MPCode desc
 
Share this answer
 
Comments
Sumon562 7-Jul-13 4:27am    
Thank you Mr. OriginalGriff
OriginalGriff 7-Jul-13 4:40am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900