if exists (select * from sys.procedures where name = 'Get_Serica_Data') Drop procedure Get_Serica_Data GO Create Procedure Get_Serica_Data AS Begin SELECT M.PointId AS "Point ID", (Convert(varchar, skfuser1.TO_DATE(DATADTG), 103) + ' ' + Convert(varchar, skfuser1.TO_DATE(DATADTG), 108)) AS "Day-time", MR.OverallValue AS "Value", P.ValueString AS "Units" FROM MEASUREMENT M inner join MEASREADING MR ON MR.MeasId = M.MeasId inner join POINT P ON P.ElementId = MR.PointId inner join MEASALARM MA ON MR.READINGID = MA.READINGID WHERE P.FieldId = ( select RegistrationId from REGISTRATION where signature = 'SKFCM_ASPF_Full_Scale_Unit') AND MR.ReadingType = ( select RegistrationId from REGISTRATION where signature = 'SKFCM_ASMD_Overall') AND MA.PointId in ( select ElementId from POINTCAT where CategoryId = ( select CategoryId from CATEGORY where ValueStr = 'SafeWellsSource' ) ) ORDER BY MA.PointId, MA.MeasId End