1.新建类库,里面写入方法,类库里必须样静态,防止实例化

mssql下调用dll

2.将dll存放到文件夹里

3.在sql中运行

EXEC sp_configure 'clr enabled' , '1'; --0代表不允许,1代表运行


CREATE ASSEMBLY ctoDll FROM 'D:\Aso\Library\ClassLibrary.dll'

CREATE FUNCTION dbo.ctoDllFuntion
(
@name as nvarchar(200)
)
RETURNS bigint  --返回类型,
AS EXTERNAL NAME ctoDll.[ClassLibrary.Md5Hash].Md5HashStr

 SELECT dbo.ctoDllFuntion('耿耿') 

调用查看

 

4.

如果出现下面错误。请运行


exec sp_configure 'show advanced options', '1';
go
reconfigure;
go
exec sp_configure 'clr enabled', '1'
go
reconfigure;
exec sp_configure 'show advanced options', '1';
go

.mssql下调用dll

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-16
  • 2021-09-28
  • 2021-08-01
  • 2022-01-04
  • 2022-01-16
猜你喜欢
  • 2021-12-29
  • 2021-11-22
  • 2021-06-28
  • 2021-12-13
  • 2022-01-08
  • 2021-06-06
相关资源
相似解决方案