Computed Column cannot be Persisted

Viewed 15522

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 'FormattedSSN' in table 'SomeTable' cannot be persisted because the column is non-deterministic.

Here is the function:

ALTER FUNCTION [dbo].[FormatSSN]()
RETURNS VARCHAR(11)
AS
BEGIN
    return '';
END

Here is the query to add the column using the function:

ALTER TABLE SomeTable
ADD FormattedSSN as dbo.FormatSSN() PERSISTED

Please suggest if there is any way out. Thanks.

4 Answers
Related