Professional Documents
Culture Documents
Notes
Purpose
Note: This function uses the ids from the shift_activities table; the shift_activities table
must be populated for this function to work.
Function:
Dbo.fn_DelimitToArray
Parameters:
@String(varchar(8000), No default)
@Delimiter(varchar(1), No default)
Examples:
Pos | Value
--------------
1 | Delimit
2 | To
3 | Array
Pos | Value
--------------
1 |364
2 |365
3 |364
4 |365
5 |364
6 |365
7 |364
8 |365
1
Technical
Notes
Code:
--
-- fn_DelimitToArray
--
-- Created by Daniel Soto on 2009-08-11
-- Copyright (c) 2009 Jigsaw Technologies. All rights reserved.
--
--
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
RETURN
(
SELECT
i - LEN(REPLACE(LEFT(@String, i-1), @Delimiter, '')) AS Pos,
SUBSTRING(@String+@Delimiter, i, CHARINDEX(@Delimiter,
@String+@Delimiter, i)-i) AS Value
FROM (select id as i from shift_activities) consecutive
WHERE i >0 AND i<LEN(@String)+LEN(@Delimiter) AND
SubString(@Delimiter + @String + @Delimiter, i, 1)=@Delimiter
)