Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zzzprojects/51393eebc7aa30596598 to your computer and use it in GitHub Desktop.
Save zzzprojects/51393eebc7aa30596598 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, '1;2' ),
( 2, '1;3;5' )
-- DECLARE expression to evaluate
DECLARE @sqlnet SQLNET = SQLNET::New('Split(s, ";").Select(x => Convert.ToInt32(x)).Where(x => x > 1)')
-- 1 | 2
-- 2 | 3
-- 2 | 5
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