DECLARE @timeTolerance FLOAT = (SELECT CAST(Value AS FLOAT) FROM Setting WHERE Name = 'DataAnalysis.TimeTolerance')
DECLARE @lineID INT
DECLARE @startTime DATETIME2
DECLARE @endTime DATETIME2

SELECT
    @lineID = AssetID,
    @startTime = dbo.AdjustDateTime2(StartTime, -@timeTolerance),
    @endTime = dbo.AdjustDateTime2(EndTime, @timeTolerance)
FROM Event
WHERE ID = {0}

SELECT *
INTO #lineEvent
FROM Event
WHERE
    Event.AssetID = @lineID AND
    Event.EndTime >= @startTime AND
    Event.StartTime <= @endTime

SELECT
    ROW_NUMBER() OVER(ORDER BY FaultSummary.Inception) FaultNumber,
    Location.Name StationName,
    Asset.AssetKey LineKey,
    FORMAT(FaultSummary.Distance, '0.##########') Distance,
    DATEADD(MINUTE, -Event.TimeZoneOffset, FaultSummary.Inception) EventTime,
    NULL EndLatitude,
    NULL EndLongitude
FROM
    #lineEvent Event JOIN
    Meter ON Event.MeterID = Meter.ID JOIN
    Location ON Meter.LocationID = Location.ID JOIN
    Asset ON Event.AssetID = Asset.ID JOIN
    FaultSummary ON
        FaultSummary.EventID = Event.ID AND
        FaultSummary.IsSelectedAlgorithm <> 0