January 9, 2019 at 7:21 am
drew.allen - Tuesday, January 8, 2019 2:06 PMMichael L John - Tuesday, January 8, 2019 1:14 PMettentrala - Tuesday, January 8, 2019 12:16 PMMy apologizes, I was wrong,Microsoft SQL Server 2014 (SP2-CU8) (KB4037356) - 12.0.5557.0 (X64) Oct 3 2017 14:56:10 Copyright (c) Microsoft Corporation Standard Edition (64-bit) on Windows NT 6.3 <X64> (Build 9600: ) (Hypervisor)
Well, Jeff Moden's string splitter is probably your best bet!
Declare @string Varchar(max) = 'Cum CA:12.0 CE:12.0 QP:42.00 QPA:3.500'
SELECT *
FROM [dbo].[DelimitedSplit8K] (@string, '.')Results:
ItemNumber ItemValue 1 Cum CA:12 2 0 CE:12 3 0 QP:42 4 00 QPA:3 5 500 There has been an update to the splitter that uses LEAD() and is about 50% faster IIRC. That is your best alternative. I believe that there is a link to the update in Jeff's article.
Drew
The improvement you speak of is buried in an article titled in a totally unrelated fashion. It was written by Eirikur Eiriksson and, yes... I tested it before he submitted the article. It is literally twice as fast thanks to the use of the "new" LEAD functionality, which became available in 2012, to replace the use of CHARINDEX() to find the "next" delimiter.
Here's the link to Eirikur's article....
http://www.sqlservercentral.com/articles/SQL+Server+2012/106903/
I should add another update to my article to make Eirikur's wonderful modification easier to find.
--Jeff Moden
Change is inevitable... Change for the better is not.
January 9, 2019 at 8:06 am
Jeffrey Williams 3188 - Tuesday, January 8, 2019 3:08 PMIf the values in the string can be in any order it gets much more difficult using a traditional string splitter. Using the XML splitter method would be easier:
And, usually, slower. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 2 posts - 16 through 17 (of 17 total)
You must be logged in to reply to this topic. Login to reply