SQL运行CLR报异常

最近的工作是导数据库,把原有库里的内容导入到新的数据库中。

遇到这么一个问题。新数据库有个表有trigger,trigger又调用一个function.function里面是运行CLR加密。(SHIT)

正常插入数据都没有问题,但是我写SQL导入数据,抛异常

An error occurred in the Microsoft .NET Framework while trying to load assembly id 655..

找了一下,微软官方有个结局方案。

To resolve the trust issue, open SQL Management and execute the following SQL statement against every restored/attached database:

You may have to run the statements below against your application database, forms, templates and object databases.

ALTER DATABASE dbname SET TRUSTWORTHY ON


You may have to run this script below against your application database, forms, templates and object databases.

--Run this script against the database that was restored.
--script start
DECLARE @master_owner sysname

SELECT @master_owner = sl.name

from master..syslogins sl

inner join sys.databases sd on

sd.owner_sid = sl.sid

where sd.name = 'master'

DECLARE @my_owner sysname

SELECT @my_owner = sl.name

from master..syslogins sl

inner join sys.databases sd on

sd.owner_sid = sl.sid

where sd.name = DB_NAME()

IF ISNULL(@my_owner, N'') <> @master_owner

BEGIN

DECLARE @SQL1 nvarchar(4000)

SET @SQL1 = N'ALTER AUTHORIZATION ON DATABASE::' + DB_NAME()

+ ' TO ' + @master_owner

EXECUTE (@SQL1)

END

GO

DECLARE @SQL nvarchar(4000)

SET @SQL = N'ALTER DATABASE ' + DB_NAME() + N' SET TRUSTWORTHY ON'

EXECUTE (@SQL)

GO

--script end

Note:
To set this option, you must be a member of the sysadmin fixed server role, which the sa user is by default.
Make sure to log into SQL Mgt Studio, with SQL authentication and the 'sa' user

转载于:https://www.cnblogs.com/orangegao/archive/2011/02/25/1964659.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值