• ;WITH

    [4] AS (SELECT n = 0 FROM (VALUES (0), (0), (0), (0)) d (n)),

    [16] AS (SELECT n = 0 FROM [4] a, [4] b),

    [256] AS (SELECT n = 0 FROM [16] a, [16] b),

    [65536] AS (SELECT n = 0 FROM [256] a, [256] b),

    iTally AS (SELECT n = ROW_NUMBER() OVER(ORDER BY (SELECT NULL))-1 FROM [65536] a, [16] b)

    SELECT a.visit_date, a.vin, a.make, x.Hour_in_service

    FROM #sampleA a

    CROSS APPLY (

    SELECT TOP (1 + DATEDIFF(hour, a.enter_datetime, a.depart_datetime))

    Hour_in_service = DATEPART(HOUR,DATEADD(hour,n,a.enter_datetime))

    FROM iTally t

    ) x

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden