I have a long CSV string that can have a maximum length of 44,119 characters. I have a SQL stored procedure that accepts 1 to 6 parameters, each of varchar(8000) that way dividing the long CSV into multiple parameters and passing it to the stored procedure.
My stored procedure works fine, but how can I divide a long CSV into different string variables such that they don't exceed string length of 8000 characters?
For example:
string myLongCSV = "1,2,345,5674,234,22,34..." //a long CSV
I cannot use SubString (0, 8000) as the 8,000th character might be breaking a number in the long CSV and not a comma.
I want to write the code in C# to make it divide all the numbers in the long CSV into different string variables making each variable length not exceeding 8000 characters.