K
K
Konstantin Kosyanov2015-01-21 10:58:31
C++ / C#
Konstantin Kosyanov, 2015-01-21 10:58:31

How do I get rid of previous results when calling a Table-Valued CLR Function?

I made a CLR assembly for MSSQL Server 2012, wrote a method that converts a string with a separator into an array of numbers:

[SqlFunction(FillRowMethodName = "FillRowCustomTable")]
public static IEnumerable Split(SqlChars value)
{
    return value.eStr().Split(';').Select(x => int.Parse(x));
}

public static void FillRowCustomTable(object resultObj, out SqlInt32 ID)
{
    ID = new SqlInt32((int)resultObj);
}

CREATE FUNCTION clr.Split(@Value NVARCHAR(MAX))
RETURNS TABLE(Value int) EXTERNAL NAME Regex.[SQLCLR.RegularExceptions].Split

Everything worked well, but after a while, the previous ones began to be added to the result.
For example:
After rebuilding the assembly, I execute the query AND I get the following results
SELECT * FROM clr.Split(@Val)
  • @Val = "2", result: 2
  • @Val = "1;2", result: 1.2
  • @Val = "1;3", result: 1.3
  • @Val = "1;3;4", result: 1,3,4
  • @Val = "1;3", result: 1,3,4
  • @Val = "9", result: 9,3,4

How to get rid of it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question