代码改变世界

[Tips]:SQL server 2005 Create Assembly Failed

2009-05-14 16:45  敏捷的水  阅读(770)  评论(0编辑  收藏  举报

今天创建SQL server2005 程序集时,提示权限失败,我是sa权限。

 

最后通过 添加如下这句才得以通过

   1: ALTER DATABASE [TestDB] SET TRUSTWORTHY ON

 

完整代码如下:

 


 


1: USE [TestDB]


   2: GO
   3: IF  EXISTS (SELECT * FROM sys.assemblies asms WHERE asms.name = N'GetImage')
   4: DROP ASSEMBLY [ImportMedia]
   5:  
   6: ALTER DATABASE [TestDB] SET TRUSTWORTHY ON
   7:  
   8: CREATE ASSEMBLY GetImageAssem
   9:   FROM 'C:\GetImage.dll'
  10: WITH PERMISSION_SET = EXTERNAL_ACCESS;
  11: GO
  12:  
  13: CREATE PROCEDURE DownloadImage
  14: (
  15:  @url nvarchar(200) 
  16: )
  17: AS EXTERNAL NAME
  18:   GetImageAssem.[GetImage.Down].DownloadImage
  19:   
  20: GO
  21:  
  22: exec DownloadImage 'http://www.hedgate.net/wp-content/uploads/polaroid-chris.png'