Computed Column cannot be Persisted

前端 未结 4 1320
自闭症患者
自闭症患者 2020-12-29 21:46

I have a custom function, and I am trying to created a persisted column using this function.

It is giving me following error.

Computed column

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-29 22:37

    How about specifying the definition directly:

    ALTER TABLE SomeTable
    ADD FormattedSSN as
        case when len(EmployeeSSN) = 9 then
                substring(EmployeeSSN, 1, 3) + '-' +
                substring(EmployeeSSN, 4, 2) + '-' +
                substring(EmployeeSSN, 6, 4)
        else EmployeeSSN end
    PERSISTED
    

提交回复
热议问题