none
Using MatLab built-in statistical functions inside SQL Server stored procedure RRS feed

  • Question

  • Hi everybody,

     

    I would like to use MatLab built-in statistical functions (beta, gamma, normal, etc.) from inside a SQLServer stored proceudre. Does anyone know if possible? (Of course, If so, where can I get documentation for doing this?)

     

    Thanks in advance!

     

    JorgeHG.

    Thursday, May 17, 2007 5:17 PM

All replies

  • Hi JorgeHG

    I was wondering if you (or anybody else) have found sollution for your problem and if you can share a code with me.

    Thanks

    h.paulina
    Friday, October 2, 2009 10:55 AM
  • How are these functions exposed? dlls maybe?
    SQL Server MVP
    Friday, October 2, 2009 1:01 PM
  • Most of the function will be wrapped in dll.
    Friday, October 2, 2009 4:17 PM
  • for dll calls, check out the sp_OA... series of system functions.  BOL has some stuff on them.  Ken Henderson's wonderful The Guru's Guide to Transact-SQL has marvelous coverage.  These are known as the OLE Automation Stored Procedures.  Code examples can be found in BOL here:  ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/e59f75a9-ed41-4f12-888e-ffc57f9b3882.htm

    If possible, you could also maybe use CLR for these capabilities, although if they are non-managed code that would carry an extra layer of Interop overhead and should probably be avoided.
    SQL Server MVP
    Friday, October 2, 2009 7:29 PM
  • If possible, you could also maybe use CLR for these capabilities, although if they are non-managed code that would carry an extra layer of Interop overhead and should probably be avoided.
    SQL Server MVP

    You can actually write these in CLR without the Interop.  The formulas are available online and if you are good doing searching you can even find CLR implementations of many of the formulas.  I have a C# gamma function that could easily be ported to SQLCLR usage.  You can find the code for the mathematical special functions in C# on the following site under GNU license:

    http://www.alglib.net/

    Jonathan Kehayias
    http://sqlblog.com/blogs/jonathan_kehayias/
    http://www.twitter.com/SQLSarg
    http://www.sqlclr.net/
    Please click the Mark as Answer button if a post solves your problem!
    Saturday, October 3, 2009 12:27 AM
    Moderator