I'm currently using function to split string separated by semicolons. The function is not able to split string 12 000 characters long. It runs for a few minutes and then SSMS freezes.
Can you please suggest me function, which is able to handle this? I will post the function I use as soon as I get to PC.
Thank you.
Function (now working as expected):
/* fce SplitList start */
Declare @CommaDelimitedFieldNames Varchar(MAX)
Declare @CharToFind VarChar(10)
Set @CommaDelimitedFieldNames = REPLACE(@String,' ','')
Set @CharToFind = ';'
Declare @Tbl_FieldNames Table
(
Position Integer Identity(1,1),
FieldName VarChar(8000)
)
Set @CommaDelimitedFieldNames = @CommaDelimitedFieldNames + @CharToFind
Declare @Pos1 Int
Declare @pos2 Int
Set @Pos1=1
Set @Pos2=1
While @Pos1<DataLength(@CommaDelimitedFieldNames)
Begin
Set @Pos1 = CharIndex(@CharToFind, @CommaDelimitedFieldNames,@Pos1)
Insert @Tbl_FieldNames Select Cast(Substring(@CommaDelimitedFieldNames,@Pos2,@Pos1-@Pos2) As NVARCHAR(MAX))
Set @Pos2=@Pos1+1
Set @Pos1 = @Pos1+1
End
/* fce Splitlist end */