CLR UDF returning Varbinary(MAX)

后端 未结 3 1180
挽巷
挽巷 2021-01-25 16:09

Is it possible for a SQL CLR User-Defined Function to return the data type varbinary(MAX)?

In the documentation it mentions:

\"The input parameters and the type

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-25 16:41

    If you define it as returning a SqlBytes data type, this should correctly map to varbinary(MAX) in SQL Server.

    [SqlFunction]
    public static SqlBytes Function1()
    {
        return new SqlBytes(Encoding.UTF8.GetBytes("Hello world."));
    }
    

    Whilst you can also use the SqlBinary data type, if you deploy via Visual Studio, it will be mapped onto varbinary(8000) rather than varbinary(MAX).

提交回复
热议问题