2021年9月1日 星期三

[MSSQL] 預存程序引用DLL參考



*在組件中加入DLL參考



*可將DLL檔案轉成bytes 直接加入參考



CREATE ASSEMBLY SQLCom

FROM 0x4D5A900003.................

WITH PERMISSION_SET = SAFE;



DLL to bytes string 參考

https://stackoverflow.com/questions/2885335/clr-sql-assembly-get-the-bytestream





 *DLL程式碼


    [Microsoft.SqlServer.Server.SqlFunction]

    public static string GZip(string rawString)

    {

       ..................

            return (string)(Convert.ToBase64String(zippedData));

    }








    * 於資料新增 擴充的 預存程序

    CREATE FUNCTION dbo.GZip(@src nvarchar(MAX))

    RETURNS nvarchar(MAX)

    EXTERNAL NAME SQLCom.UserDefinedFunctions.GZip





*SQL指令
    SELECT dbo.GZip(S_String)




 

MangoHost Copyright © 2009 Cookiez is Designed by Ipietoon for Free Blogger Template