Newbie wants to split comma delimited string.

Newbie wants to split comma delimited string.

Post by Robert Jorda » Thu, 07 Feb 2002 07:57:20



Hi All,

Sorry for being such a lamer, but I need to parse a comma delimited value.
This sort of thing is a piece of cake in VB or PERL, but I can't find a way
to do it in TSQL.  Is there a SPLIT-like function I can use, or do I have to
roll my own?

Thanks,
Robert Jordan

 
 
 

Newbie wants to split comma delimited string.

Post by Hirantha S. Hettiarachch » Thu, 07 Feb 2002 08:01:34


Robert,

try
http://www.algonet.se/~sommar/examples_of_lists.html

--
hth
Hirantha S Hettiarachchi MCSD,MCDBA,OCP

Please reply only to the newsgroups.
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc.) which
can be cut and pasted into Query Analyzer is appreciated.


> Hi All,

> Sorry for being such a lamer, but I need to parse a comma delimited value.
> This sort of thing is a piece of cake in VB or PERL, but I can't find a
way
> to do it in TSQL.  Is there a SPLIT-like function I can use, or do I have
to
> roll my own?

> Thanks,
> Robert Jordan



 
 
 

Newbie wants to split comma delimited string.

Post by Greg Patnud » Fri, 08 Feb 2002 00:15:34


subStr(string, 0, find(',', string)) ???

> Hi All,

> Sorry for being such a lamer, but I need to parse a comma delimited value.
> This sort of thing is a piece of cake in VB or PERL, but I can't find a way
> to do it in TSQL.  Is there a SPLIT-like function I can use, or do I have to
> roll my own?

> Thanks,
> Robert Jordan


 
 
 

1. Help need to split comma separated string into distinct values and count for each

Platform: SQL Server 2000 - ASP application

 Any help on this would be much appreaciated.

 I have a table with a column that has comma separated values inserted
from a web form that allows the selection of a predefined list of
multiple items. In addition a user can add their own unique values in
an "other" text box which get appended to the selection of the muliple
list box. The results look like the ouput below in the table after the
insert. Where there may be one value or a comma separated list where
some elements are predefined choices and some are user defined
additions to the comma separated list. I had a feeling this was going
to bite me at the point when i needed to aggregate those values
(COUNT) individually.

I have looked at an SP from MSDN called Fn_Split() to help but could
not get it to work correctly.

trying to help a non-profit for at risk kids convert some data to help
with their funding, but this one is beyond me.

Thanks,
Max

The output of the column

ChildPCGovAID
-------------------------------------------
Food stamps
Food stamps, Medical
Food stamps, Medical, Child care subsidy
Food stamps, Medical, Child care subsidy, Public housing/Section 8
Food stamps, Medical, Child care subsidy, Public housing/Section 8
Food stamps, Medical, Child care subsidy, Public housing/Section 8
Food stamps, Medical, Child care subsidy, Public housing/Section 8
Food stamps, Medical, Child care subsidy, Public housing/Section 8
Food stamps, Medical, SSI
Food stamps, Medical, SSI
Food stamps, Medical, TANF, Child care subsidy, Public housing/Section
8
Food stamps, Medical, TANF, SSI ,  wic
Food stamps, Medical, TANF, wic
Food stamps, Medical, wic
Food stamps, Medical, wic

Need something like this as the output

Food stamps         15
Medical             15
Child care subsidy   7
WIC                  4

Thanks again

2. Oracle Objects for OLE - runtime error 2827

3. splitting non-delimited string

4. @Datetime in concatenated Select

5. bcp comma-delimited files with quoted strings ?

6. First N records in SELECT

7. How to loop the comma delimited string in SP

8. GI-Hypertext Mailing List

9. Rows to Comma-Delimited String in SP?

10. Use a comma-delimited string for IN operator

11. Insert a comma delimited string into a table

12. Looping through Comma Delimited String

13. Insert Values from a Comma delimited variable string?