CLR - T-SQL and CLR types for return value do not match
I am really sorry for the lame questions but I have not got any C# experience but want to test [this] CLR splitter function. I have build the `rdl` and created an assembly, but I am not able to create the T-SQL function itself. This is part of the CLR function: [Microsoft.SqlServer.Server.SqlFunction( FillRowMethodName = "FillRow_Multi", TableDefinition = "item nvarchar(4000)" ) ] This is the function definition: CREATE FUNCTION [dbo].fnParseStringCLR(@string [nvarchar](MAX), @separator [nchar](255)) RETURNS TABLE ( item nvarchar (4000) ) WITH EXECUTE AS CALLER AS EXTERNAL NAME CLR_Splitter.UserDefinedFunctions.FillRow_Multi I this is the error I a getting: > Msg 6551, Level 16, State 2, Procedure > fnParseStringCLR, Line 1 CREATE > FUNCTION for "fnParseStringCLR" failed > because T-SQL and CLR types for return > value do not match. :
If you copied Adam's code exactly (based on the link in the question), then the part that follows the first code block in the question is: public static IEnumerator SplitString_Multi( [SqlFacet(MaxSize = -1)] SqlChars Input, [SqlFacet(MaxSize = 255)] SqlChars Delimiter ) and hence the final line of the function definition (i.e. the second code block posted in the question) should be: EXTERNAL NAME CLR_Splitter.UserDefinedFunctions.SplitString_Multi Notice that the 3rd item of the `EXTERNAL NAME` -- SplitString_Multi -- matches the name of the method (between `IEnumerator` and `(` ).