Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zzzprojects/b9f28072093f320ca450 to your computer and use it in GitHub Desktop.
Save zzzprojects/b9f28072093f320ca450 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, 'b;a' ),
( 2, 'c;a;b' )
-- DECLARE expression to evaluate
DECLARE @sqlnet SQLNET = SQLNET::New('Split(s, ";").OrderBy(x => x)')
-- 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