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