Those colons within the date-time data are going to make this a bit convoluted. Having said that...`
declare @tbl table (
csvdata varchar(400)
)
insert into @tbl(csvdata)
values
('{"CreatedDate":"17.08.2015 08:56:55","CreatedBy":"t131987","Message":"CES, Manual Check, AB","LinkTitle":null,"LinkURL":null}'),
('{"CreatedDate":"14.08.2015 09:10:38","CreatedBy":"t131987","Message":"CES, Manual Check, KSP","LinkTitle":null,"LinkURL":null}')
--/**/select * from @tbl
select
substring(s.Element, charindex('":"', s.Element) + 3, 100)
from
@tbl t
outer apply
dbo.SplitIt(csvdata, '","') s
-- dbo.parseCSV(csvdata, '","')
where
s.ElementId = 3
go
CREATE FUNCTION [dbo].[SplitIt] (
@vcDelimitedString varchar(8000),
@vcDelimiter varchar(100)
)
/*
** ScriptName: SplitIt
**
** Description: Accepts a delimited string and splits it at the specified
** delimiter points. Returns the individual items as a table data
** type with the ElementID field as the array index and the Element
** field as the data
** @vcDelimitedString - The string to be SplitIt
** @vcDelimiter - String containing the delimiter where
** delimited string should be SplitIt
**
** Returns: Table data type containing array of strings that were SplitIt with
** the delimiters removed from the source string
** sample call:
** SELECT ElementID, Element FROM SplitIt('11111,22222,3333', ',') ORDER BY ElementID
**
*/
RETURNS @tblArray TABLE
(
ElementID smallint IDENTITY(1,1), --Array index
Element varchar(1000) --Array element contents
)
AS
BEGIN
DECLARE @siIndex smallint
DECLARE @siStart smallint
DECLARE @siDelSize smallint
SELECT @siDelSize = LEN(@vcDelimiter)
--loop through source string and add elements to destination table array
WHILE LEN(@vcDelimitedString) > 0
BEGIN
SELECT @siIndex = CHARINDEX(@vcDelimiter, @vcDelimitedString)
IF @siIndex = 0
BEGIN
INSERT INTO @tblArray VALUES(@vcDelimitedString)
BREAK
END
ELSE
BEGIN
INSERT INTO @tblArray
VALUES(SUBSTRING(@vcDelimitedString, 1,@siIndex - 1))
SELECT @siStart = @siIndex + @siDelSize
SELECT @vcDelimitedString = SUBSTRING(@vcDelimitedString, @siStart , LEN(@vcDelimitedString) - @siStart + 1)
END
END
RETURN
END
`
It's not the fastest string splitter in the world but it does return an index number for each element which I've used to select the Nth element.