I have a persisted computed column which calls a Scalar Valued Function
. As you know, this function needs to be deterministic in order to persist the value. Even if REPLACE function behaves in a deterministic way(I can't think a case where it's not), SQL Server seems to interpret it as nondeterministic. Therefore, I can not use it in the function.
What I try to do is converting some non-english characters to english. Case sensitivity is important here. I wanted to convert the letters of ğĞüÜşŞıİöÖçÇ
to gGuUsSiIoOcC
respectively. I can achieve it(in a "nondeterministic" way) simply by using something like:
SET @ColumnValue = REPLACE(@ColumnValue COLLATE SQL_Latin1_General_CP1253_CS_AS, 'ı', 'i') --This character("ı") is converted to "?" after collation so that I manually replace it
SET @ColumnValue = @ColumnValue COLLATE SQL_Latin1_General_CP1253_CS_AS --This line takes care of the other characters
SQL Server interprets this code above as nondeterministic (demo) because of REPLACE
and COLLATE
(I think that it's deterministic though..).
Another thing that I tried was using CHARINDEX with STUFF in a WHILE
loop but needed to use collation because of the need of case sensitivity. Without the collation, SQL Server treats it as deterministic though.
What are my options?