Why is my CASE expression non-deterministic?

前端 未结 2 1593
夕颜
夕颜 2020-12-10 17:18

I am trying to create a persisted computed column using CASE expression:

ALTER TABLE dbo.Calendar ADD PreviousDate AS 
case WHEN [Date]>\'20100101\' THEN          


        
2条回答
  •  一整个雨季
    2020-12-10 17:35

    Apparently it is very picky about data types. Try doing this:

    ALTER TABLE dbo.Calendar ADD PreviousDate AS 
    case WHEN [Date ]> Convert(DateTime, '20100101', 101) THEN  [Date]
        ELSE Convert(DateTime, NULL, 101)
        END PERSISTED
    

提交回复
热议问题