Split words with a capital letter in sql

Monday, May 5, 2014

anyone knows how to split words starting with capital letters from a string?


Example:



DECLARE @var1 varchar(100) = 'OneTwoThreeFour'
DECLARE @var2 varchar(100) = 'OneTwoThreeFourFive'
DECLARE @var3 varchar(100) = 'One'

SELECT @var1 as Col1, <?> as Col2
SELECT @var2 as Col1, <?> as Col2
SELECT @var3 as Col1, <?> as Col2


expected result:



Col1 Col2
OneTwoThreeFour One Two three Four
OneTwoThreeFourFive One Two Three Four Five
One One


If this is not possible (or if too long) an scalar function would be okay as well.


Thanks in advance.







http://ift.tt/1kNZwXZ