Home Forums SQL Server 7,2000 T-SQL Scalar function result into temp table column RE: Scalar function result into temp table column

  • without re-writing the scalar function to be an inline table valued function, i though getting intermediate results for the scalar function in a CTE or sub select would be easier:

    i'm assuming the first two not null columns constitute a PK for the data at hand:

    WITH myIntermediateResults

    AS

    (

    SELECT rmc.*,

    NewTargetDate = dbo.fn_GetTargetTimeInServiceHours(rmc.project_id, rmc.folder_id, rmc.sla_start_date, (rmc.hold_time + @target_time))

    FROM #request_meet_criteria rmc

    rmc.smx_active_flag = 0

    )

    update rmc

    set rmc.sla_target_date = myIntermediateResults.NewTargetDate

    from #request_meet_criteria rmc

    INNER JOIN myIntermediateResults

    ON rmc.project_id = myIntermediateResults.project_id

    AND rmc.request_id = myIntermediateResults.request_id

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!