Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zzzprojects/934150b303b447fc297d to your computer and use it in GitHub Desktop.
Save zzzprojects/934150b303b447fc297d 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;3;4;5' ),
( 2, '2;4;6;8' ),
( 3, '3;6')
-- DECLARE expression to evaluate
DECLARE @sqlnet SQLNET = SQLNET::New('Split(s, ";").Sum(x => Convert.ToInt32(x))')
-- 1 | 15
-- 2 | 20
-- 3 | 9
SELECT RowID ,
@sqlnet.ValueString('s', DelimitedString).EvalString()
FROM @SourceTable
ORDER BY RowID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment