zoukankan      html  css  js  c++  java
  • SQL Server 引用dll文件与执行exe程序

    一、引用dll文件

    create assembly text    --创建名称
    from 'D:odoodemoinDebug	ext.dll'      --dll文件路径
    with permission_set = UNSAFE 

    注:执行时可能会出现程序集‘xxx’未获授权的错误,可以设置数据库的trustworthy 为 on 解决:

    alter database [database] set trustworthy on

    二、创建函数

    create FUNCTION [dbo].[test1]( ) --该函数的名字
    RETURNS nvarchar(200) --返回的类型
    WITH EXECUTE AS CALLER
    AS 
    EXTERNAL NAME [ODS].[ODS.ods].[test] --[ODS]是指你程序集中dll的名称, [ODS.ods]ODS是指dll文件中那个类的命名空间,ods是指dll文件中那个类的类名,[test]是指dll文件中那个被调用的静态方法
    GO

    三、调用函数

    print dbo.test1()

    注:如果出现禁止在 .NET Framework 中执行用户代码。启用 "clr enabled" 配置选项的错误,可执行以下命令解决:

    #执行sql server的CLR支持
    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

    四、执行exe程序

    EXEC sp_configure 'xp_cmdshell', 1
    GO
    RECONFIGURE
    GO
    ----xp_cmdshell { 'command_string' } [ , no_output ]
    
    --执行
    EXEC xp_cmdshell 'D:odoodemo1inDebug	est.exe'

    学习文章:https://www.cnblogs.com/xiaozhuxing/p/11172181.html

           https://www.cnblogs.com/WEI-CONG/p/4324715.html?utm_source=tuicool&utm_medium=referral

           https://blog.csdn.net/karen586/article/details/78064529

           https://www.cnblogs.com/ling-cun/p/9114971.html

  • 相关阅读:
    Codeforces 526D Om Nom and Necklace (KMP)
    HDU
    HDU
    Codeforces 219D
    HDU
    HDU
    POJ
    HDU
    HDU
    第二次作业
  • 原文地址:https://www.cnblogs.com/da-tong/p/12511215.html
Copyright © 2011-2022 走看看