Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zzzprojects/d41d18c1c7173f585f0f to your computer and use it in GitHub Desktop.
Save zzzprojects/d41d18c1c7173f585f0f to your computer and use it in GitHub Desktop.
-- CREATE test table
DECLARE @SourceTable TABLE
(
RowID INT ,
DelimitedString VARCHAR(8000)
)
INSERT INTO @SourceTable
VALUES ( 1, 'a;a;b' ),
( 2, 'a;b;c;b;b;a;c;a' )
-- DECLARE expression to evaluate
DECLARE @sqlnet SQLNET = SQLNET::New('Split(s, ";").Distinct()')
-- 1 | a
-- 1 | b
-- 2 | a
-- 2 | b
-- 2 | c
SELECT RowID ,
Value_1
FROM @SourceTable
CROSS APPLY ( SELECT Value_1
FROM dbo.SQLNET_EvalTVF_1(@sqlnet.ValueString('s',
DelimitedString))
) AS SplitTable
ORDER BY RowID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment