November 13, 2013 at 1:35 pm
Comments posted to this topic are about the item Split and concatenate function
Tomaž Kaštrun | twitter: @tomaz_tsql | Github: https://github.com/tomaztk | blog: https://tomaztsql.wordpress.com/
November 26, 2013 at 8:00 am
January 31, 2014 at 10:23 am
The best splitter for T-SQL is right here[/url] along with several tests. It will outperform any splitter using while loops or xml.
With it, you can replace your function to this. Note that it has a limit to 4000 unicode chars (8000 for non-unicode) to avoid the use of large data types and improve performance.
-- Split and concatenate back to string
CREATE FUNCTION [dbo].[Split_and_concatenate]
(
@STR NVARCHAR(4000)
,@delimiter CHAR(1)
)
RETURNS NVARCHAR(8000)
AS
BEGIN
SELECT STUFF( (SELECT '; ' + CASE Item WHEN '1' THEN '11'
WHEN '2' THEN '22'
ELSE '33' END
FROM dbo.[DelimitedSplitN4K](@str, @delimiter)
FOR XML PATH('')),1,2, '')
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply