我用C#写了一个类,代码如下:
using System;
using System.Collections.Generic;
using System.Text;namespace ExtendedProc
{
    public class Test
    {
        public string Say()
        {
            return "ExtendedProcedure test success!";
        }
    }
}
编译为DLL以后,放在目录D:\Program Files\Microsoft SQL Server\MSSQL\Binn下,执行
EXEC sp_addextendedproc Say,'D:\Program Files\Microsoft Visual Studio 8\VC\ExtendedProc.dll'然后运行一下看看
EXEC Say提示:
ODBC: 消息 0,级别 16,状态 1
无法在库 D:\Program Files\Microsoft Visual Studio 8\VC\ExtendedProc.dll 中找到函数 Say。原因: 127(找不到指定的程序。)。
怎么解决

解决方案 »

  1.   

    sp_addextendedproc
    将新扩展存储过程的名称注册到 Microsoft® SQL Server™ 上。语法
    sp_addextendedproc [ @functname = ] 'procedure' ,
        [ @dllname = ] 'dll'参数
    [ @functname = ] 'procedure'在动态链接库 (DLL) 内调用的函数名称。procedure 的数据类型为 nvarchar(517),没有默认设置。procedure 能够可选地包含 owner.function 形式的所有者名称。[ @dllname = ] 'dll'包含该函数的 DLL 名称。dll 的数据类型为 varchar(255),没有默认设置。返回代码值
    0(成功)或 1(失败)
      

  2.   

    参考《SQLSERVER2000存储过程与XML 第二版》一书,里面有注册扩展存储过程的介绍,SUNDERIC著。
    扩展存储过程一定要小心,搞不好就把SQLSERVER搞崩溃了。