I wrote a User Defined Function that gets a UtcTimeStamp and a windowstimezoneid as parameters and returns the TimeStamp for the TimeZone.
But if i want to execute it in a simple select i get the following error:
A .NET Framework error occurred during execution of user-defined routine or aggregate "ToLocalTime":
System.Security.HostProtectionException: Attempted to perform an operation that was forbidden by the CLR host.
The protected resources (only available with full trust) were: All
The demanded resources were: MayLeakOnAbort
System.Security.HostProtectionException:
bei TimeFunctions.ToLocalTime(DateTime UtcTimestamp, String WindowsTimeZoneId)
I execute the select as sa. I set clr enabled to 1. I use SQL Server 2008 R2 (10.50.1600).
Does anyone know what i have to set to get this working or what i may done wrong?