How to create CLR stored procedure with Nvarchar(max) parameter?

后端 未结 2 1810
长情又很酷
长情又很酷 2020-12-19 13:17

Is it possible to create CLR stored procedure in SQL Server CLR project having input parameterof type nvarchar(max)?

If you define stored procedure:

2条回答
  •  时光取名叫无心
    2020-12-19 13:33

    You can use the SqlFacet attribute. If you want the NVARCHAR(MAX) type as a parameter, then you should do this:

    [SqlProcedure]
    public static void storedProcedure1([SqlFacet(MaxSize=-1)] String param){ .. }
    

    If you need it as a return value in a user defined function:

    [return:SqlFacet(MaxSize=-1)]
    [SqlFunction]
    public static String userFunction1(){ ... }
    

    The MaxSize=-1 indicates that the size of the NVARCHAR will be MAX.

提交回复
热议问题