开发者

SQLCLR & IronPython

Im feeling crazy and I've decided I would really like to write a User-Defined Function in Python that would run in SQL Server 2008. I am interested in doing this as I have a few thousand lines of PL/Python functions written for PostgreSQL and I am interested to know if I can get the project running on SQL Server instead.

I am looking at IronPython for the first time trying to work out if I can convert something like this C#...

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

public partial class UserD开发者_StackOverflow中文版efinedFunctions
{
    [Microsoft.SqlServer.Server.SqlFunction]
    public static SqlString Function1()
    {
        // Put your code here
        return new SqlString("Hello");
    }
};

... into Python.

Has anyone got any ideas on this one? Is it possible?

The bit I am particularly perplexed by is the annotation:

[Microsoft.SqlServer.Server.SqlFunction]

How do I write that in Python? Looks a bit like a decorator :)

All suggestions welcome.

Cheers, Tom


According to this article you're wasting your time trying. Apparently you simply can't use dynamic languages in SQL CLR even in UNSAFE assemblies.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜