• Another problem linked to this one..

    The query works fine now, even if i don't like not being able to write "jprod as....query treatement here"

    What if i need to define the computed column "jprod" as persisted?

    I tried to put the keyword PERSISTED wherever it could be and i got an error in each case.

    SELECT [NUMCAM]

    ,[date_passage]

    ,[heure_passage]

    ,[anneeprod]

    ,(CASE WHEN heure_passage BETWEEN '00:00:00' and '05:59:59' THEN day(date_passage) - dbo.jprodtestannee(anneeprod)

    ELSE day(date_passage) - dbo.jprodtestannee(anneeprod) +1

    END) as jprod

    FROM dbo.GlobaldataEOLT8

    GO

    I tried to re-write the query the way i feel more comfortable with :

    ..jprod as (CASE WHEN....) PERSISTED but the error remains, can't get it solved.