-- ================================= 删除先 ================================= --
-- MyCLRSqlserver 为程序集部署名称
IF EXISTS ( SELECT * FROM sys.assemblies asms WHERE asms. name = N 'MyCLRSqlserver' and is_user_defined = 1)
BEGIN
-- 删除集合函数。
IF EXISTS ( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N '[dbo].[StrJoin]' ) AND type = N 'AF' )
DROP AGGREGATE dbo.StrJoin;
-- 删除标量函数。
IF EXISTS ( SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N '[dbo].[___fun_CLR_ChangeSalarieScope]' ) AND type in (N 'FN' , N 'IF' , N 'TF' , N 'FS' , N 'FT' ))
DROP FUNCTION dbo.___fun_CLR_ChangeSalarieScope;
-- 删除其它...
-- 卸载程序集。
DROP ASSEMBLY [MyCLRSqlserver];
END ;
-- ================================= 重新创建 ================================= --
-- 注册程序集(如果是在服务器上部署,需要将此dll复制到服务器,然后修改文件地址)。
CREATE ASSEMBLY [MyCLRSqlserver] FROM 'G:\AA\XX.dll' ;
---------------------- [dbo].[StrJoin] ----------------------
CREATE AGGREGATE [dbo].[StrJoin]
(@Value [nvarchar](4000))
RETURNS [nvarchar](4000)
EXTERNAL NAME [MyCLRSqlserver].[MyCLRSqlserver.StrJoin]
GO
EXEC sys.sp_addextendedproperty @ name =N 'AutoDeployed' , @value=N 'yes' , @level0type=N 'SCHEMA' ,@level0name=N 'dbo' , @level1type=N 'AGGREGATE' ,@level1name=N 'StrJoin'
GO
EXEC sys.sp_addextendedproperty @ name =N 'SqlAssemblyFile' , @value=N 'StrJoin.cs' , @level0type=N 'SCHEMA' ,@level0name=N 'dbo' , @level1type=N 'AGGREGATE' ,@level1name=N 'StrJoin'
GO
EXEC sys.sp_addextendedproperty @ name =N 'SqlAssemblyFileLine' , @value=14 , @level0type=N 'SCHEMA' ,@level0name=N 'dbo' , @level1type=N 'AGGREGATE' ,@level1name=N 'StrJoin'
GO
-- 其它函数创建过程...
-- ================================= END ================================= --
|