how to substract word from the list of words | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

how to substract word from the list of words

Hi Guys, One of the column in a table contain the list of values like ‘hello, thanks, movies, tickets’, I want substract word one by one. Please help me Thanks in adv.
lkarthik

CREATE FUNCTION dbo.GetResultSetFromStringList
(
@csvString varchar(8000)
)
RETURNS @CsvResults TABLE (csvcode varchar(4000))
AS
BEGIN
DECLARE @off int
DECLARE @substr varchar(4000)
DECLARE @nextValue varchar(4000)
DECLARE @prevOff int SELECT @prevOff = 1
SELECT @off = CHARINDEX(‘,’, @csvString, 0) WHILE (@off > 0)
BEGIN
SELECT @nextValue = RTRIM(SUBSTRING(@csvString, @prevOff, @[email protected]))
SELECT @prevOff = @off+1
insert into @CsvResults (csvcode) Values (@nextValue)
SELECT @off = CHARINDEX(‘,’, @csvString, @prevoff)
END if (LEN(@csvString)[email protected]+1 > 0)
BEGIN
— if string did not terminate with a trailing comma
SELECT @nextValue = RTRIM(SUBSTRING(@csvString, @prevOff, LEN(@csvString)[email protected]+1))
insert into @CsvResults (csvcode) Values (@nextValue)
END return
END select LTRIM(RTRIM(csvcode)) from dbo.GetResultSetFromStringList(‘hello, thanks, movies, tickets’)

Hi,
refer below link : http://www.mindsdoor.net/SQLTsql/ParseCSVString.html Hemantgiri S. Goswami
[email protected]
"Humans don’t have Caliber to PASS TIME , Time it self Pass or Fail Humans" – by Hemantgiri S. Goswami

]]>