[dba-VB] Sql Server 2008 VTF and SQL CLR

Francisco Tapia fhtapia at gmail.com
Thu Dec 15 13:48:34 CST 2011


have any of you worked with Table Valued Functions yet?  I know how to
create a SQL value table function in pure TSQL, but getting one to work
that's built off of SQL CLR is something new entirely to me  :phew:  My
sample here is simple, but the idea is that I'm going to be calling a
webservice to collect some data.  I'd like to have at least a two column
table returned so that I can create labels or maybe a multi-column with the
appropriate column name.

here is my working code from c# and this does yield me a working returned
table.

As always your help is appreciated!

  [Microsoft.SqlServer.Server.SqlFunction(FillRowMethodName = "getFillRow",
     TableDefinition = "Field1 nvarchar(20)")]
    public static IEnumerable fngetTEST(string strSomeInput)
    {
        ArrayList myList = new ArrayList();
        myList.Add("test1");
        myList.Add("test2");
        return new ArrayList(myList);
    }
    private static void getFillRow(object obj,
        out SqlString strField1

        )
    {
        strField1 = Convert.ToString(obj);
    }


-Francisco
http://bit.ly/sqlthis   | Tsql and More...
<http://db.tt/JeXURAx>



More information about the dba-VB mailing list