July 19, 2018 at 1:11 pm
I have a table which contains produce information which is separated by | . I need to separate those values but don't know how. I am wondering if someone can help me with this. Please see attachments for more details.
July 19, 2018 at 1:36 pm
Do you have a split string function already? If not you can find one here http://www.sqlservercentral.com/scripts/T-SQL/100014/
Then simple call to it
select *
from #Commodity
cross apply [dbo].[fn_SplitString](Commodity,'|')
For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
July 19, 2018 at 1:51 pm
Mike01 - Thursday, July 19, 2018 1:36 PMDo you have a split string function already? If not you can find one here http://www.sqlservercentral.com/scripts/T-SQL/100014/
Then simple call to it
select *
from #Commodity
cross apply [dbo].[fn_SplitString](Commodity,'|')
Not necessarily the best function. If you aren't using MAX data types, look here: http://www.sqlservercentral.com/articles/Tally+Table/72993/.
July 19, 2018 at 9:10 pm
Lynn Pettis - Thursday, July 19, 2018 1:51 PMMike01 - Thursday, July 19, 2018 1:36 PMDo you have a split string function already? If not you can find one here http://www.sqlservercentral.com/scripts/T-SQL/100014/
Then simple call to it
select *
from #Commodity
cross apply [dbo].[fn_SplitString](Commodity,'|')Not necessarily the best function. If you aren't using MAX data types, look here: http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Because of the shortcomings of spt_values and the fact that the function concatenates the final delimiter, I'll have to recommend against using the fn_SplitString function. A part of the reason why I rewrote the original DelimitedSplit8K was because of how badly that kind of concatenation slows things down.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply