[Tips]:SQL server 2005 Create Assembly Failed

今天创建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'

你可能感兴趣的:(sql server 2005)