Register the time a machine running in a timerange using sql
The following code will spray your one row into 2 as desired.

Declare @starttime time
Declare @endtime time
Declare @machinename varchar(10)
Set @machinename = 'vxx:2019'
If OBJECT_ID ('tempdb..#A') is not null Drop Table #A
Create Table #A (machinename varchar(15), startdatetime datetime, enddatetime datetime, timerunning int, timerange varchar(10))
Insert into #A (machinename, startdatetime, enddatetime, timerunning, timerange)
Select 'vxx:2019',    '2020-02-07 13:45:18.790' ,   '2020-02-07 16:00:38.920' , 135, '12:00'

Select @starttime = cast(startdatetime as time)
from #A
where machinename = @machinename

Select @endtime = cast(enddatetime as time)
from #A
where machinename = @machinename

If (@starttime  between '12:00' and '14:00') and (@endtime &gt; '14:00')

Begin
Select machinename, startdatetime, enddatetime, datediff(minute,@starttime,'14:00') as timerunning, '12:00' as timerange
from #A
UNION ALL
Select machinename, startdatetime, enddatetime, datediff(minute,'14:00',@endtime), '2:00' as timerange
From #A
End



The two time ranges specified in the question are 12-2 and 2 - end time. It uses variables to determine whether the job runs across the time range or not. If the job runs across the time range then it just uses the datediff function to determine the time running in those timeranges and sprays it out into two rows. If you need to do this on a whole table a while loop is probably your best bet.