2010-08-17 86 views
4

我觉得很疯狂,我决定我真的很想在Python中编写一个用户定义的函数,它可以在SQL Server 2008中运行。我对这样做感兴趣,因为我有几千行PL /为PostgreSQL编写的Python函数,我很想知道是否可以让项目在SQL Server上运行。SQLCLR&IronPython

我在看IronPython的首次努力工作,如果我可以把这样的事情C#...

using System; 
using System.Data; 
using System.Data.SqlClient; 
using System.Data.SqlTypes; 
using Microsoft.SqlServer.Server; 

public partial class UserDefinedFunctions 
{ 
    [Microsoft.SqlServer.Server.SqlFunction] 
    public static SqlString Function1() 
    { 
     // Put your code here 
     return new SqlString("Hello"); 
    } 
}; 

...成Python。

有没有人对此有任何意见?可能吗?

尤其使我感到困惑的位注释:

[Microsoft.SqlServer.Server.SqlFunction]

我如何写在Python?看起来有点像装饰者:)

欢迎任何建议。

干杯, 汤姆

回答

2

根据this article你是在浪费你的时间尝试。显然,即使在UNSAFE程序集中,您也无法在SQL CLR中使用动态语言。