Greetings BackLet me re-phrase my question (with a bit more detail this time).Select His.Enterprise_nbr, Max (his.maint_date) as Maint_dateinto #vwTempfrom SQL.sms_system.dbo.history_reo as hiswhere (his.survey_code = 'Agri2002' or His.Survey_code = 'Agri2003')Group by His.Enterprise_nbr Select T.enterprise_nbr, T.maint_date, Hi.capture_codeinto #vwTempRes as Tfrom #vwTemp Inner join SQL.sms_system.dbo.history_reo as Hion t.enterprise_nbr = Hi.enterprise_nbrwhere t.maint_date = Hi.maint_dateand (reo_code = '25' or Reo_code = '28')Select *from #vwTempResorder by Enterprise_nbr
If any of the #temp tables (#vwTemp or #vwTempRes) already exist then I want to drop them then run this statementCan/Should I include an if or Case statement?You can't teach an old mouse new clicks.