I want to split comma-separated String
inside SQLite database
Example: I have a Category
column in 1 of my table.
|Category
please create this function in your sqllite and pass 2 argument first is seprator and second string.
CREATE FUNCTION [dbo].[Split]
(
@Sep char(1)
, @S varchar(512)
)
RETURNS TABLE
AS
RETURN
(
WITH Pieces(pn, start, stop) AS (
SELECT 1, 1, CHARINDEX(@Sep, @S)
UNION ALL
SELECT pn + 1, stop + 1, CHARINDEX(@Sep, @S, stop + 1)
FROM Pieces
WHERE stop > 0
)
SELECT pn,
SUBSTR(@S, start, CASE WHEN stop > 0 THEN stop-start ELSE 512 END) AS S
FROM Pieces
)