我编写了一个用户定义函数,它获取UtcTimeStamp和
windowstimezoneid作为参数,并返回TimeZone的TimeStamp.
但如果我想在一个简单的选择中执行它我得到以下错误:
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)
我执行select as sa.我将clr设置为1.我使用sql Server 2008 R2(10.50.1600).
有谁知道我必须设置什么才能使这个工作或我可能做错了什么?
解决方法
CLR程序集有
trust levels.
这个需要UNSAFE权限,因为使用“MayLeakOnAbort”所需的权利