Upto SQL Server 2008 R2 I think, we don't have better option than this but in SQL Server 2012 with some extra added function it might be possible.
DECLARE @tblTemp TABLE
(
ID INT
, TextValue NVARCHAR(500)
)
INSERT INTO @tblTemp
SELECT 1, 'text|text|text'
UNION
SELECT 2, 'text|text|text'
SELECT * FROM @tblTemp
DECLARE
@ID INT,
@Data NVARCHAR(MAX),
@Expression NVARCHAR(5);
DECLARE @Temp TABLE
(
ID INT,
Data NVARCHAR(100)
)
DECLARE TempCursor CURSOR FORWARD_ONLY STATIC FOR
SELECT ID, TextValue, '|' FROM @tblTemp
-- Open cursor and try to fetch first element
OPEN TempCursor
FETCH NEXT FROM TempCursor INTO @ID, @Data, @Expression
-- loop while fetch returned next item
WHILE @@FETCH_STATUS = 0
BEGIN
-- Do the processing
DECLARE @Index INT
SET @Index = 1
WHILE (CHARINDEX(@Expression, @Data) > 0)
BEGIN
INSERT INTO @Temp(ID, data)
SELECT @ID, Data = LTRIM(RTRIM(SUBSTRING(@Data, 1, CHARINDEX(@Expression, @Data)-1)))
SET @Data = SUBSTRING(@Data, CHARINDEX(@Expression, @Data) + 1, LEN(@Data))
SET @Index = @Index + 1
END
INSERT INTO @Temp (ID, Data)
SELECT @ID, Data = LTRIM(RTRIM(@Data))
-- fetch next entry
FETCH NEXT FROM TempCursor INTO @ID, @Data, @Expression
END
-- Close and deallocate cursor
CLOSE TempCursor
DEALLOCATE TempCursor
SELECT DISTINCT * FROM @Temp