I'm using SQL 2008 (not R2). When I try to define the following UDF and try to use it in a computed column, I get the ever popular "cannot be persisted because the column is non-deterministic". set ansi_nulls on go set quoted_identifiers on go create function [dbo].[RemoveNonAlphanumeric] ( @input nvarchar(100) ) returns nvarchar(100) AS BEGIN declare @i int, @result nvarchar(100), @pattern nvarchar(100); set @pattern = '%[^a-zA-Z0-9]%'; set @result = @input; set @i = patindex( @pattern, @result); while @i > 0 begin set @result = STUFF( @result, @i, 1, '' ); set @i = patindex( @pattern, @result ); end return @result; END using `SELECT OBJECTPROPERTYEX( object_id('dbo.RemoveNonAlphanumeric'), 'IsDeterministic' )` gives back zero. I've tried changing both `ansi_nulls` and `quoted_identifier` to OFF with no effect on the determinism of the function. I've even replaced the body of the UDF with a simple `return N'';` and SQL Server STILL says it is non-deterministic. I am simply not seeing what is non-deterministic. Any help would be apprectiated.