SQL CLR Stored Procedure 创建脚本

本脚本用于创建已生成dll及序列化dll至数据库。【记录,已备查看】

SP_CONFIGURE  ' clr enabled ' 1
GO
RECONFIGURE
GO

ALTER   DATABASE  DATABASE_NAME  SET  TRUSTWORTHY  ON
GO

USE  DATABASE_NAME
GO

IF    EXISTS  ( SELECT   *   FROM  sys.objects  WHERE   object_id   =   OBJECT_ID (N ' [dbo].[Test] ' AND  type  in  (N ' P ' , N ' PC ' ))
    
DROP   PROCEDURE   [ dbo ] . [ Test ]
GO

IF   EXISTS  ( SELECT   [ name ]   FROM  sys.assemblies  WHERE   [ name ]   =  N ' Test.XmlSerializers '
    
DROP  ASSEMBLY  [ Test.XmlSerializers ]
GO

IF   EXISTS  ( SELECT   [ name ]   FROM  sys.assemblies  WHERE   [ name ]   =  N ' Test '
    
DROP  ASSEMBLY  [ Test ]
GO

CREATE  ASSEMBLY Test
FROM   ' E:\path\Test.dll '
WITH  PERMISSION_SET  =  UNSAFE
GO

// 序列化dll路徑
CREATE  ASSEMBLY  [ Test.XmlSerializers ]
FROM   ' E:\path\Test.XmlSerializers.dll '
WITH  PERMISSION_SET  =  SAFE
GO

CREATE   PROCEDURE  Test
(    
    
@NO_COMP      NVARCHAR ( 10 ),    
     @BegDate      NVARCHAR ( 10 ),    
     @EndDate      NVARCHAR ( 10 )    
)
AS
EXTERNAL NAME Test.StoredProcedures.Test
GO

你可能感兴趣的:(procedure)