So wondering if this sql code can have a statemet put in it that will do the following.
It runs the query as printed below but it checks to see if a specific feild is null.
So for instance this query currently does not have the field [appraisefinal]. I want it to while running this query do some if statements and say if appraisefinal is null then insert [appraisal ordered] into the item of outlookreport.dbo.calendar
;WITH MyCTE AS
EventDate FOR DateDescription in ([Appraisal Ordered],[Closing Date],[Application Signed],[Appraisal Recieved] ,[Approval To Close],[Insurance Ordered],[Title Ordered])
) as unpvt
insert into outlookreport.dbo.calendar (eventdate,item,xrefid)
FROM emdb.dbo.calendarview T
JOIN MyCTE M
ON T.xrefid = M.xrefid
WHERE NOT EXISTS(SELECT 1 FROM outlookreport.dbo.calendar WHERE eventdate = M.EventDate AND xrefid = T.xrefid);