Skip to content

Instantly share code, notes, and snippets.

-- CREATE test
DECLARE @t TABLE (Id INT , Input VARCHAR(MAX))
INSERT INTO @t VALUES ( 1, '1, 2, 3; 4; 5' ), ( 2, '6;7,8;9,10' )
-- SPLIT with many delimiters: ',' and ';'
DECLARE @sqlnet SQLNET = SQLNET::New('Regex.Split(input, ",|;")')
SELECT *
FROM @t AS A
CROSS APPLY ( SELECT *
-- CREATE test table
DECLARE @SourceTable TABLE
(
RowID INT ,
DelimitedString VARCHAR(8000) ,
ArrayIndex INT
)
INSERT INTO @SourceTable
VALUES ( 1, 'a;b;c;d;e', 0 ),
-- 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' ),
-- CREATE test table
DECLARE @SourceTable TABLE
(
RowID INT ,
DelimitedString VARCHAR(8000)
)
INSERT INTO @SourceTable
VALUES ( 1, 'a;b' ),
( 2, 'a;b;c' )
-- CREATE test table
DECLARE @SourceTable TABLE
(
RowID INT ,
DelimitedString VARCHAR(8000)
)
INSERT INTO @SourceTable
VALUES ( 1, 'b;a' ),
( 2, 'c;a;b' )
-- 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' )
-- CREATE test table
DECLARE @SourceTable TABLE
(
RowID INT ,
DelimitedString VARCHAR(8000)
)
INSERT INTO @SourceTable
VALUES ( 1, '1;2' ),
( 2, '1;3;5' )
-- CREATE test table
DECLARE @SourceTable TABLE
(
RowID INT ,
DelimitedString VARCHAR(8000)
)
INSERT INTO @SourceTable
VALUES ( 1, 'a;b' ),
( 2, 'a;b;c' )
-- CREATE test table
DECLARE @SourceTable TABLE
(
RowID INT ,
DelimitedString VARCHAR(8000)
)
INSERT INTO @SourceTable
VALUES ( 1, 'a;a;b' ),
( 2, 'c;b;c;b;b;a;c;a' ),
@zzzprojects
zzzprojects / 0_reuse_code.js
Created March 17, 2016 18:55
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console