Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zzzprojects/802fc3fa9fcc2c470e92 to your computer and use it in GitHub Desktop.
Save zzzprojects/802fc3fa9fcc2c470e92 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;b' ),
( 2, 'a;b;c' )
-- DECLARE expression to evaluate
DECLARE @sqlnet SQLNET = SQLNET::New('Split(s, ";").Select((x, i) => new {i, x })')
-- 1 | 0 | a
-- 1 | 1 | b
-- 2 | 0 | a
-- 2 | 1 | b
-- 2 | 2 | c
SELECT RowID ,
Value_1 ,
Value_2
FROM @SourceTable
CROSS APPLY ( SELECT Value_1 ,
Value_2
FROM dbo.SQLNET_EvalTVF_2(@sqlnet.ValueString('s',
DelimitedString))
) AS SplitTable
ORDER BY RowID, Value_1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment