I have an existing C# CLR runtime function that I am using with SQL Server 2012. I would like to set the IsDeterministic and SCHEMABINDING options on this function so I can use it for persisting a computed column in a table.
Here is the alter statement:
ALTER FUNCTION [dbo].[authorityFromURI](@URI [nvarchar](4000))
RETURNS [nvarchar](4000) WITH EXECUTE AS CALLER
AS
EXTERNAL NAME [KDPSqlServerProject].[UserDefinedFunctions].[authorityFromURI]
How should this alter statement be modified to set these options?
You have to set the IsDeterminstic property within the function code itself, e.g
[SqlFunction(IsDeterministic = true, IsPrecise = true [...])]
To make it schemabinding:
RETURNS NVARCHAR(4000)
WITH SCHEMABINDING, EXECUTE AS CALLER
That said, I haven't tested these options together with persistence...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With