Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing a string to count 2

Status
Not open for further replies.

redtoad

Programmer
Jan 28, 2002
51
US
I need to get a count on the number of values in a string.

For instance, my query returns something like this:

'1000,2000,3000'

I need a count of 3 returned (as a varchar). Or if the data returned is '1000', I need a count of 1 returned.

Any help would be appreciated.
 
Interesting Solution. However I think you forgot something. I think the code should read as follows

select len(c) - len(replace(c,',','')) + 1 from t
 
Thanks stravis and swampBoogie, that's just what I was looking for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top