Skip to content

Instantly share code, notes, and snippets.

@DanielAdeniji
Created September 11, 2022 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanielAdeniji/0469db241eeff638a876f511d6f72aca to your computer and use it in GitHub Desktop.
Save DanielAdeniji/0469db241eeff638a876f511d6f72aca to your computer and use it in GitHub Desktop.
Transact SQL - String Split - Jack and Jill
declare @rhyme varchar(8000)
declare @CHAR_SEPARATOR char(1)
set @rhyme
= 'Jack and Gill went up the hill '
+ 'To fetch a pail of water '
+ 'Jack fell down and broke his crown '
+ 'And Gill came tumbling after.'
set @CHAR_SEPARATOR = ' '
SELECT
itvfSS.ordinal
, itvfSS.[value]
FROM STRING_SPLIT
(
@rhyme
, @CHAR_SEPARATOR
, 1
) itvfSS
order by
itvfSS.ordinal asc
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment