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.
Add WITH SCHEMABINDING to the function like this:
and then run this to verify:
Works here.