delimited split gives null for some items

elsvieta 346 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
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,117 questions
SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
58 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,583 questions
{count} votes

1 answer

Sort by: Most helpful
  1. elsvieta 346 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