delimited split gives null for some items

elsvieta 371 Reputation points
2024-05-29T13:43:14.27+00:00

hi all,

I am using a function to split a string into multiple rows. The function is available here:

https://www.sqlservercentral.com/articles/tally-oh-an-improved-sql-8k-%e2%80%9ccsv-splitter%e2%80%9d-function

What I am trying to figure out is how to increase the size of Item since a whole bunch of values come up as NULL:

User's image

In the example above, the text for item 1000000 has been truncated, so Item #4 shows up. Had I not deleted most of the text, I would have has what can be seen at ID 1000005.

I am not sure what I need to modify in the function to make it work with larger strings than apparently are allowed.

thanks,

elsvieta

SQL Server | SQL Server Transact-SQL
Developer technologies | Transact-SQL
SQL Server | Other
{count} votes

1 answer

Sort by: Most helpful
  1. elsvieta 371 Reputation points
    2024-05-29T14:59:29.1066667+00:00

    hi all,

    sorry for the confusion, the issue was with the query used to view this split ...

    I simply changed the query from:

    select		logtbl.content_TBL_ID, logtbl.content, split.ItemNumber, Item = QUOTENAME(split.Item, '''')  
    from		TBL_RSManagementLog logtbl
    CROSS APPLY	dbo.DelimitedSplit8K(logtbl.content, '|') split 
    order by	content_TBL_ID
    
    

    to

    select		logtbl.content_TBL_ID, logtbl.content, split.ItemNumber, Item = split.Item 
    from		TBL_RSManagementLog logtbl
    CROSS APPLY	dbo.DelimitedSplit8K(logtbl.content, '|') split 
    order by	content_TBL_ID
    
    

    and everything is fine now.

    Thanks,

    elsvieta

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.