I have a logging functionality that is executed on each start and end of a table transfer process. It creates a separate entry for both start and stop:
Between each distinct table transfer there is a DB restore process that is not logged:

There is no feasible pattern in the execution (log) times that I can use and base my DATEDIFF on.
I have two questions:
- How do I unite the logs for the TransferingTables process so that each logid line represent the proces start and end, opposite to two lines as is now?
- How do I create an entry for the DB restore process that is not being logged?
Sample DDL and DML:
CREATE TABLE #temptableTimeStamps
(
[logid] INT,
[procesid] INT,
[Object] VARCHAR(17),
[Started] DATETIME2(7),
[Finished] DATETIME2(7)
);
INSERT INTO #temptableTimeStamps
(
logid,
procesid,
Object,
Started,
Finished
)
VALUES
(1, 00000000, 'TransferingTables', N'2020-11-01T04:19:20.2666667', N'2020-11-01T04:19:20.2666667'),
(2, 00000000, 'TransferingTables', N'2020-11-01T20:23:36.39', N'2020-11-01T20:23:36.39'),
(3, 00000000, 'TransferingTables', N'2020-11-01T22:09:13.5766667', N'2020-11-01T22:09:13.5766667'),
(4, 00000000, 'TransferingTables', N'2020-11-02T03:48:34.6733333', N'2020-11-02T03:48:34.6733333'),
(5, 00000000, 'TransferingTables', N'2020-12-01T12:08:15.8466667', N'2020-12-01T12:08:15.8466667'),
(6, 00000000, 'TransferingTables', N'2020-12-01T15:31:42.4633333', N'2020-12-01T15:31:42.4633333'),
(7, 00000000, 'TransferingTables', N'2020-12-01T17:13:04.26', N'2020-12-01T17:13:04.26'),
(8, 00000000, 'TransferingTables', N'2020-12-01T20:16:52.25', N'2020-12-01T20:16:52.2633333'),
(9, 00000000, 'TransferingTables', N'2020-12-14T16:32:22.96', N'2020-12-14T16:32:22.96'),
(10, 00000000, 'TransferingTables', N'2020-12-14T23:08:09.5566667', N'2020-12-14T23:08:09.5566667'),
(11, 00000000, 'TransferingTables', N'2020-12-15T01:15:24.3766667', N'2020-12-15T01:15:24.3766667'),
(12, 00000000, 'TransferingTables', N'2020-12-15T11:39:43.1733333', N'2020-12-15T11:39:43.1733333');
