Created
September 11, 2022 02:53
-
-
Save DanielAdeniji/0469db241eeff638a876f511d6f72aca to your computer and use it in GitHub Desktop.
Transact SQL - String Split - Jack and Jill
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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